-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pygettext --docstrings
doesn't actually extract module docstring due to tokenize returning ENCODING token
#95731
Labels
type-bug
An unexpected behavior, bug, or error
Comments
JelleZijlstra
pushed a commit
that referenced
this issue
Oct 15, 2022
miss-islington
added a commit
that referenced
this issue
Oct 15, 2022
JelleZijlstra
pushed a commit
that referenced
this issue
Oct 16, 2022
Now that backports are merged, I think this can be closed. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug report
When running
pygettext --docstrings file.py
on Python 3.7 and above, the module docstring does not get extracted.Reproduction steps:
repro.py
with the following contents (actually you can omit everything but the first three lines):python pygettext.py --docstrings repro.py
messages.pot
that was created and see that it doesn't contain the module docstring:The reason for this appears to be that pygettext doesn't account for
token.ENCODING
which was added in Python 3.7.A simple solution for this would be to skip
tokenize.ENCODING
here:cpython/Tools/i18n/pygettext.py
Lines 338 to 340 in 29650fe
This actually reveals another bug which is caused by the
return
in the line 340 - detection of module docstring causes pygettext to swallow one token without handling it. This means that for a code like this:pygettext
will not extract the docstring of class X once the solution gets applied if proper care isn't taken. I'm mentioning it so that the fix is tested with both of these cases.Your environment
The
pygettext.py
script was taken directly from this repository, I'm not sure that my distro even has a package that ships it.The text was updated successfully, but these errors were encountered: