-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
test_timestamp_overflow of test_importlib fails if PYTHONDONTWRITEBYTECODE is set #70770
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
Comments
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: |
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? |
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. |
The problem is that I have PYTHONDONTWRITEBYTECODE set in my environment. Should the setUp and tearDown methods ensure that PYTHONDONTWRITEBYTECODE is cleared and reset? |
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 (bpo-20796 documents a similar problem and workaround for test_import). |
LGTM, Ned. |
New changeset 915f158633f4 by Ned Deily in branch '3.5': New changeset e8cab14d8a47 by Ned Deily in branch 'default': |
Pushed for release in 3.5.2 and 3.6.0. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: