classification
Title: pygettext ignores directories as inputfile argument
Type: behavior Stage: resolved
Components: Demos and Tools Versions: Python 3.8, Python 3.7, Python 3.6, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Oleg Krasnikov, miss-islington, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2017-11-02 08:37 by Oleg Krasnikov, last changed 2018-04-10 08:04 by serhiy.storchaka. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4225 closed Oleg Krasnikov, 2017-11-02 08:55
PR 6259 merged serhiy.storchaka, 2018-03-26 15:59
PR 6431 merged miss-islington, 2018-04-09 17:09
PR 6432 merged miss-islington, 2018-04-09 17:10
PR 6436 merged serhiy.storchaka, 2018-04-09 19:08
Messages (7)
msg305406 - (view) Author: Oleg Krasnikov (Oleg Krasnikov) * Date: 2017-11-02 08:37
This happens because pygettext's `getFilesForName` calls `os.walk` as if it was `os.path.walk`. But the `walk` function has changed signature when moved from `os.path` to `os`. So now `_visit_pyfiles` is passed to `walk` as `topdown` argument which is obviously wrong and therefore `_visit_pyfiles` is never called.
msg305479 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-11-03 13:15
Thank you for your patch Oleg. 3.4 and 3.5 are in security fixes only mode now.

Good catch, the usage of os.walk() in pygettext.py is incorrect. But your change is not enough. In _visit_pyfiles() the name 'CVS' is removed from the names list. If names is a list of directories emitted by os.walk(), this would exclude the whole directory CVS from searching. But if it is a new list "dirs + files", this doesn't have any effect. And directories with the ".py" extension shouldn't be added to the list of Python files. Hence _visit_pyfiles should take two separate lists for directories and files. And since it no longer is a callback, it would be better to inline its code.

There are tests for pygettext in Lib/test/test_tools/test_i18n.py. It would be nice to add a new test for the fixed feature.
msg305488 - (view) Author: Oleg Krasnikov (Oleg Krasnikov) * Date: 2017-11-03 15:36
Thanks for quite sensible notes Serhiy. I've fixed all that in recent commit and added a regression test. Still not sure about "testing conventions" here cause this is my first PR to python repository, so please let me know if something is wrong and I'll fix that.
msg315140 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-04-09 17:09
New changeset c93938b5beea4c3f592119ebee6d4029558db8de by Serhiy Storchaka in branch 'master':
bpo-31920: Fixed handling directories as arguments in the ``pygettext`` script. (GH-6259)
https://github.com/python/cpython/commit/c93938b5beea4c3f592119ebee6d4029558db8de
msg315143 - (view) Author: miss-islington (miss-islington) Date: 2018-04-09 17:57
New changeset 9b25bd6e26b50ade8d52a85c78d957b1f6f9131c by Miss Islington (bot) in branch '3.7':
bpo-31920: Fixed handling directories as arguments in the ``pygettext`` script. (GH-6259)
https://github.com/python/cpython/commit/9b25bd6e26b50ade8d52a85c78d957b1f6f9131c
msg315144 - (view) Author: miss-islington (miss-islington) Date: 2018-04-09 18:06
New changeset e0dbc57e116516f6ca1ef021f71e1a98773d57ed by Miss Islington (bot) in branch '3.6':
bpo-31920: Fixed handling directories as arguments in the ``pygettext`` script. (GH-6259)
https://github.com/python/cpython/commit/e0dbc57e116516f6ca1ef021f71e1a98773d57ed
msg315162 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2018-04-10 08:04
New changeset a61f5da54772b0ea6a7eccf21df08e61585ef712 by Serhiy Storchaka in branch '2.7':
[2.7] bpo-31920: Fixed handling directories as arguments in the ``pygettext`` script. (GH-6259) (GH-6436)
https://github.com/python/cpython/commit/a61f5da54772b0ea6a7eccf21df08e61585ef712
History
Date User Action Args
2018-04-10 08:04:26serhiy.storchakasetstatus: open -> closed
stage: patch review -> resolved
resolution: fixed
versions: + Python 3.8
2018-04-10 08:04:01serhiy.storchakasetmessages: + msg315162
2018-04-09 19:08:02serhiy.storchakasetpull_requests: + pull_request6131
2018-04-09 18:06:11miss-islingtonsetmessages: + msg315144
2018-04-09 17:57:55miss-islingtonsetnosy: + miss-islington
messages: + msg315143
2018-04-09 17:10:27miss-islingtonsetpull_requests: + pull_request6128
2018-04-09 17:09:38miss-islingtonsetpull_requests: + pull_request6127
2018-04-09 17:09:23serhiy.storchakasetmessages: + msg315140
2018-03-26 15:59:23serhiy.storchakasetstage: needs patch -> patch review
pull_requests: + pull_request5982
2017-11-03 15:36:15Oleg Krasnikovsetmessages: + msg305488
2017-11-03 13:15:42serhiy.storchakasetversions: + Python 2.7, Python 3.6, Python 3.7, - Python 3.4
nosy: + serhiy.storchaka

messages: + msg305479

stage: patch review -> needs patch
2017-11-02 08:55:34Oleg Krasnikovsetkeywords: + patch
stage: patch review
pull_requests: + pull_request4193
2017-11-02 08:37:20Oleg Krasnikovcreate