-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-130197: pygettext: Test the --escape
option
#131902
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aren't tests test_not_escaped and test_escaped redundant if we can use escapes.pot
? We can just add _()
with a long string that contain interesting characters in range 1-255.
Test for codes 127-255 look incorrect. They should produce a pair of escapes in utf-8 encoding.
Needed tests for Python sources with non-UTF-8 encoding.
I thought about it, but I was worried it'd be hard to review such long strings. I pushed a new change that does that just to see how it would look. Let me know what you think! I use the same source
Do you mean that just in context of escaping or you want to have some tests in general that use non-utf8 sources? |
Both. We need this to test with and without |
I'll gladly add it, though there is currently no way to specify the input encoding in pygettext - it uses the file object encoding which is locale-dependent. In tests we use Note that |
The |
That'd be even better! And no, we don't do that currently, we do Other than that I think I addressed your review, is there anything else I should add now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Thanks @tomasr8 for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12. |
Thanks @tomasr8 for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13. |
Sorry, @tomasr8 and @serhiy-storchaka, I could not cleanly backport this to
|
Sorry, @tomasr8 and @serhiy-storchaka, I could not cleanly backport this to
|
Thanks Serhiy! It might be easier to not backport this as some of the test infrastructure this PR relies on was not backported. I'll double-check later when I have time. |
GH-132032 is a backport of this pull request to the 3.13 branch. |
GH-132033 is a backport of this pull request to the 3.12 branch. |
Adds tests for the
-E/--escape
option in pygettext. This option controls how non-ascii strings are written to the POT file.If the option is not set, characters are written as is. If the option is set, non-ascii characters are encoded using octal escape sequences (
unicode-escape
). For example,α
becomes\316\261
.