[proxy] web.archive.org← back | site home | direct (HTTPS) ↗ | proxy home | ◑ dark◐ light
/ cpython Public
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

bpo-31920: Fix pygettext directory walk #4225

Closed

Conversation

Copy link

insolite commented Nov 2, 2017

Can be backported to >=3.4 I think.

https://bugs.python.org/issue31920

Copy link

the-knights-who-say-ni commented Nov 2, 2017

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA).

Unfortunately our records indicate you have not signed the CLA. For legal reasons we need you to sign this before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

Thanks again to your contribution and we look forward to looking at it!

Copy link
Member

serhiy-storchaka left a comment

LGTM, but please test also bugs of your initial version. This can be easy done with the same test method.

  1. Add the CVS directory and put a Python file with an unique message in it. This message shouldn't be found in the result file.

  2. Create a directory with the '.py' extension. pygettext should not fail trying to open it.

source_dir = 'pypkg'
text = 'Text to translate'
with temp_cwd(None) as cwd:
with temp_dir(os.path.join(cwd, source_dir)) as sdir:
Copy link
Member

serhiy-storchaka Nov 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to use temp_dir(None) and test with a path that is not a child of the current directory. If pygettext.py ignores the argument and searches from the current directory, it will pass the current test, but not the test with independent test directory.

text = 'Text to translate'
with temp_cwd(None) as cwd:
with temp_dir(os.path.join(cwd, source_dir)) as sdir:
with open(os.path.join(sdir, 'pymod.py'), 'w') as sfile:
Copy link
Member

serhiy-storchaka Nov 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to put the test file deeper in the directory tree, e.g. in os.path.join(sdir, 'pypkg', 'pymod.py'). This would test that directories are searched recursively.

data = fp.read()
msgids = re.findall(r'msgid "(.*?)"', data)

self.assertIn(text, msgids)
Copy link
Member

serhiy-storchaka Nov 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't be simpler to test the containment directly in the file content?

self.assertIn('msgid "%s"' % text, data)

Copy link
Member

serhiy-storchaka commented Nov 3, 2017

Please add a news entry in the Misc/NEWS.d/next/Tools-Demos directory (don't forget to add "Patch by Oleg Krasnikov.") and add your name in Misc/ACKS.

Copy link
Contributor

larryhastings commented Nov 25, 2017

3.4 and 3.5 are only accepting security fixes now.

Copy link
Member

serhiy-storchaka left a comment

Add a news entry, your name in Misc/NEWS, and additional tests.

Copy link

bedevere-bot commented Feb 26, 2018

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

Copy link
Member

serhiy-storchaka commented Apr 10, 2018

Tests have been updated in #6259.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants