Issue 26583: test_timestamp_overflow of test_importlib fails if PYTHONDONTWRITEBYTECODE is set (original) (raw)

Created on 2016-03-17 17:16 by inglesp, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue26583.patch ned.deily,2016-03-17 19:23 review
Messages (8)
msg261919 - (view) Author: Peter Inglesby (inglesp) * Date: 2016-03-17 17:16
I get the following test failure against changeset 100576 on OSX 10.9.5: $ ./python.exe -m test test_import [1/1] test_import test test_import failed -- Traceback (most recent call last): File "/Users/peteringlesby/src/cpython/Lib/test/test_import/__init__.py", line 301, in test_timestamp_overflow os.stat(compiled) FileNotFoundError: [Errno 2] No such file or directory: '__pycache__/@test_68937_tmp.cpython-36.pyc' 1 test failed: test_import
msg261922 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2016-03-17 17:41
Sorry, I am unable to reproduce this on either 10.9.5 or current 10.11.3 OS X systems. Is there something unusual about the working directory you are running the tests from, like residing on an NFS or other networked file system? Any special ./configure options? Does the test always fail?
msg261927 - (view) Author: Peter Inglesby (inglesp) * Date: 2016-03-17 18:37
I can reproduce it reliably. I ran ./configure with --with-pydebug. I'm not using NFS, and I'm not aware of anything else unusual about my filesystem. The fact that a timestamp overflows in the failing test is a red herring -- the following also fails, with os.stat raising FileNotFoundError: def test_without_timestamp_overflow(self): sys.path.insert(0, os.curdir) try: source = TESTFN + ".py" compiled = importlib.util.cache_from_source(source) with open(source, 'w') as f: pass __import__(TESTFN) os.stat(compiled) finally: del sys.path[0] remove_files(TESTFN) I've verified that TESTFN does get imported by writing 'print("hello")' to the source file.
msg261929 - (view) Author: Peter Inglesby (inglesp) * Date: 2016-03-17 18:50
The problem is that I have PYTHONDONTWRITEBYTECODE set in my environment. Should the setUp and tearDown methods ensure that PYTHONDONTWRITEBYTECODE is cleared and reset?
msg261930 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2016-03-17 19:23
Ah, setting PYTHONDONTWRITEBYTECODE explains it. When running the tests via "make test", python is invoked with -E to avoid issues like that. But here's a patch that skips test_timestamp_overflow if bytecode files cannot be written (Issue20796 documents a similar problem and workaround for test_import).
msg261931 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2016-03-17 19:50
LGTM, Ned.
msg261937 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-03-17 21:57
New changeset 915f158633f4 by Ned Deily in branch '3.5': Issue #26583: Skip test_timestamp_overflow in test_import if bytecode https://hg.python.org/cpython/rev/915f158633f4 New changeset e8cab14d8a47 by Ned Deily in branch 'default': Issue #26583: merge from 3.5 https://hg.python.org/cpython/rev/e8cab14d8a47
msg261938 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2016-03-17 21:59
Pushed for release in 3.5.2 and 3.6.0.
History
Date User Action Args
2022-04-11 14:58:28 admin set github: 70770
2016-03-17 21:59:29 ned.deily set status: open -> closedresolution: fixedmessages: + stage: commit review -> resolved
2016-03-17 21:57:14 python-dev set nosy: + python-devmessages: +
2016-03-17 19:50:49 brett.cannon set assignee: larry -> ned.deilynosy: - larry
2016-03-17 19:50:36 brett.cannon set nosy: + larrymessages: + assignee: larrystage: patch review -> commit review
2016-03-17 19:23:33 ned.deily set files: + issue26583.patchcomponents: - macOStitle: test_timestamp_overflow fails -> test_timestamp_overflow of test_importlib fails if PYTHONDONTWRITEBYTECODE is setkeywords: + patchnosy: + brett.cannon, - ronaldoussorenversions: + Python 3.5messages: + stage: patch review
2016-03-17 18:50:25 inglesp set messages: +
2016-03-17 18:37:42 inglesp set messages: +
2016-03-17 17:41:13 ned.deily set messages: +
2016-03-17 17:23:38 SilentGhost set nosy: + ronaldoussoren, ned.deilytype: behaviorcomponents: + macOS, Tests
2016-03-17 17:16:47 inglesp create