Skip to content

2.3.3 distutils extract_messages misparses --keywords #388

Closed

Description

@ajaeger

We run in OpenStack to extract only the "_LW" keyword the following:

python setup.py extract_messages --no-default-keywords
--keyword _LW
--add-comments Translators:
--input-dirs ${modulename}
--output-file ${POT}

With babel 2.3.3 the --no-default-keywords has no effect, the files contain far too much content.

Activity

  1. changed the title [-]Babel 2.3.3 breaks[/-] [+]no-default-keywords has no effect in 2.3.3[/+] on Apr 13, 2016
  2. self-assigned this
    on Apr 13, 2016
  3. ajaeger commented on Apr 13, 2016

    @ajaeger
    Author

    To reproduce:
    git clone git.openstack.org/openstack/cinder
    cd cinder
    python setup.py extract_messages --no-default-keywords --keyword _LW --input-dirs cinder --output-file test233.pot

  4. ajaeger commented on Apr 13, 2016

    @ajaeger
    Author

    Sorry, couldn't come up with a self contained test quickly.

  5. akx commented on Apr 13, 2016

    @akx
    Member

    @ajaeger: Can you see if it has an effect if you run via pybabel and not via distutils commands? Just to help narrow down the scope of the issue.

  6. ajaeger commented on Apr 13, 2016

    @ajaeger
    Author

    For smaller testcase:
    $ mkdir test
    $ cp cinder/service.py test/
    $ python setup.py extract_messages --no-default-keywords --keyword _LW --input-dirs test --output-file test233.pot

    Note that it does not include the _LW strings at all, only the default _

  7. ajaeger commented on Apr 13, 2016

    @ajaeger
    Author

    @akx
    pybabel extract --no-default-keywords -k '_LW' test -o test233.pot

    Works fine for me, the content is as expected. Only _LW is extracted

  8. akx commented on Apr 13, 2016

    @akx
    Member

    @ajaeger Okiedoke, thanks.

    I'd like to take this moment to point out that distutils' command mangling code is byzantine and strange, especially if one is used to modernities like click, argparse or even optparse... :)

  9. ajaeger commented on Apr 13, 2016

    @ajaeger
    Author

    @akx, just tested that Babel 2.3.2 handles this case fine.

  10. ajaeger commented on Apr 13, 2016

    @ajaeger
    Author

    @akx, thanks for looking into this nevertheless!

  11. akx commented on Apr 13, 2016

    @akx
    Member

    Ah, the bug is actually not in --no-default-keywords being disrespected, it's in how the keyword string gets parsed.

    I instrumented the extraction function to parse the args and die, and I get

    python setup.py extract_messages --no-default-keywords --keyword _LW
    {'_': None, 'L': None, 'W': None}
    
  12. changed the title [-]no-default-keywords has no effect in 2.3.3[/-] [+]2.3.3 distutils extract_messages misparses --keywords[/+] on Apr 13, 2016
  13. ajaeger commented on Apr 13, 2016

    @ajaeger
    Author

    How did it work in 2.3.2 and earlier?

  14. akx commented on Apr 13, 2016

    @akx
    Member

    2.3.3 changed that particular parsing code to do things differently to have the pybabel commands work correctly with multiple keywords (your issue #384), but unfortunately broke support for distutils arguments. In short

    • versions 2.3.0..2.3.2 break multiple -k/--keywords arguments for pybabel extract
    • version 2.3.3 breaks the single -k/--keywords argument accepted by distutils extract_messages

    I'll try and get a bugfix in asap. Honestly I'm a little embarrassed by these.

  15. 2 remaining items

  16. added a commit that references this issue on Apr 14, 2016
    46d9a93
  17. akx commented on Apr 14, 2016

    @akx
    Member

    @ajaeger: Would you be able to test that all of Openstack's usecases (since apparently some of your processes use pybabel as evident from #384 and others use the distutils-based commands as evident here) work with the code in #389?

  18. ajaeger commented on Apr 14, 2016

    @ajaeger
    Author

    @akx I can test the common two use cases, just tell me if you have something to test.

    I've wrote also a patch to use only pybabel in OpenStack infra scripts - one issue less to test. Let's see what the reviewers think.

  19. ajaeger commented on Apr 15, 2016

    @ajaeger
    Author

    Sorry, misread your notice, @akx. You already told me what to test. I did some testing and it looks fine to me. Thanks!

  20. added a commit that references this issue on Apr 19, 2016
    414aec5
  21. added a commit that references this issue on May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions