[issue21520] Erroneous zipfile test failure if the string 'bad' appears in pwd
Larry Hastings added the comment: Checked in, with the filter function on a separate line, to 3.4. Also merged into 3.5. -- resolution: - fixed stage: commit review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21520 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21520] Erroneous zipfile test failure if the string 'bad' appears in pwd
Roundup Robot added the comment: New changeset bff966aed6a3 by Larry Hastings in branch '3.4': Issue #21520: test_zipfile no longer fails if the word 'bad' appears https://hg.python.org/cpython/rev/bff966aed6a3 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21520 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21520] Erroneous zipfile test failure if the string 'bad' appears in pwd
Serhiy Storchaka added the comment: The line is too long. It would be better to extract a filter as regular function. Otherwise LGTM. -- nosy: +serhiy.storchaka stage: needs patch - commit review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21520 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21520] Erroneous zipfile test failure if the string 'bad' appears in pwd
Changes by Ismail Badawi ism...@badawi.io: -- nosy: +ismail.badawi ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21520 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21520] Erroneous zipfile test failure if the string 'bad' appears in pwd
Larry Hastings added the comment: With this patch applied the test passes. (Patch is against 3.4 branch.) Look good? -- keywords: +patch Added file: http://bugs.python.org/file35567/larry.bad.zipfile.1.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21520 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21520] Erroneous zipfile test failure if the string 'bad' appears in pwd
Ned Deily added the comment: Yep -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21520 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21520] Erroneous zipfile test failure if the string 'bad' appears in pwd
New submission from Larry Hastings: If you extract current Python (3.4 or trunk) into a directory, and anywhere in the name of the directory is the string bad, such as /tmp/badtest /home/baddison/src/python then test_write_filtered_python_package() in Lib/test/test_zipfile.py will fail. The reason is, the third subtest uses a filterfunc to ignore certain files, and its test to ignore files is effectively bad in fn (fn is an ill-conceived abbreviation for filename) This is overbroad. Changing it to Lib/test/bad in fn prevents this error. I'm creating this issue just to remind myself to fix it. 3.4.1 is tagged and I didn't want to re-cut the release, but I didn't feel like pushing it while 3.4.1 hadn't landed in trunk yet. -- assignee: larry components: Tests messages: 218735 nosy: larry priority: normal severity: normal stage: needs patch status: open title: Erroneous zipfile test failure if the string 'bad' appears in pwd type: behavior versions: Python 3.4, Python 3.5 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21520 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21520] Erroneous zipfile test failure if the string 'bad' appears in pwd
Changes by Georg Brandl ge...@python.org: -- nosy: +georg.brandl ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21520 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21520] Erroneous zipfile test failure if the string 'bad' appears in pwd
Larry Hastings added the comment: Here's an eye-wateringly-thorough description of the bug for the sake of posterity. The test code in question is test_write_filtered_python_package() in Lib/test/test_zipfile.py. This function uses PyZipFile to build a zipfile from the contents of the Lib/test directory. PyZipFile scans for .py files, then compiles them into .pyc or .pyo files and adds the compiled result. The test code actually reuses the PyZipFile object three times: The first try succeeds, but raises some warnings because of some deliberately troublesome files in that directory that upset the compiler. These files all contain the substring bad in their name, like Lib/test/bad_coding.py. The warnings are written to stdout; the test captures stdout and scans for the errors. When this function is done, the zipfile contains .pyc files of all the files in Lib/test except for the ones with the substring bad in their name. The second try succeeds, but ignores every file because of a filterfunc passed in that always returns False. It's effectively a no-op--no files are added to the zipfile. The test then scans the output to make sure no warnings were issued. The third try succeeds. It uses the filterfunc parameter to selectively skip the bad files, then scans stdout to ensure that no warnings were issued there. However, since it's re-adding all the other files to the zipfile, this does issue a zillion UserWarning assert warnings. The code suppresses these with a self.assertWarns(UserWarning) context manager. So here's the bug. If you untarred Python into /tmp/goodidea, then the test works as expected. But if you untar Python into /tmp/badidea, then the filterfunc in the third test ignores *every* file, because *every* file contains the substring bad. Therefore it never adds a single file. And therefore it never fires the UserWarning about redundantly adding a file. Since UserWarning is never issued, and the test is supposed to issue it, the assertWarns context manager flags the test as a failure. The easy fix: change the filterfunc to be far more selective, only filtering out paths containing the substring Lib/test/bad. This would still fail if you untarred Python to /tmp/Lib/test/bad/, but hopefully nobody will do *that*. Perhaps a still-better approach would be lambda path: os.path.basename(path).startswith(bad) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21520 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21520] Erroneous zipfile test failure if the string 'bad' appears in pwd
Ned Deily added the comment: Testing for Lib/test/bad isn't correct either since the test will fail when the tests are run from an installed Python rather than just from a build directory. -- nosy: +ned.deily ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21520 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com