Issue 8727: test_import failure - Python tracker (original) (raw)

Created on 2010-05-15 21:10 by pitrou, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (9)
msg105825 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-05-15 21:10
[...] test_import Warning -- sys.path was modified by test_import test test_import failed -- Traceback (most recent call last): File "/home/antoine/py3k/__svn__/Lib/test/test_import.py", line 167, in test_module_with_large_stack exec('import ' + module) File "", line 1, in File "/home/antoine/py3k/__svn__/Lib/importlib/_bootstrap.py", line 151, in decorated return fxn(self, module) File "/home/antoine/py3k/__svn__/Lib/importlib/_bootstrap.py", line 320, in load_module code_object = self.get_code(module.__name__) File "/home/antoine/py3k/__svn__/Lib/importlib/_bootstrap.py", line 429, in get_code "object for {0!r}".format(fullname)) ImportError: no source or bytecode available to create code object for 'longlist'
msg105829 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-05-15 21:43
This can be narrowed down to the following test sequence: $ ./python -E -m test.regrtest test_heapq test_import test_heapq test_import Warning -- sys.path was modified by test_import test test_import failed -- Traceback (most recent call last): File "/home/antoine/py3k/__svn__/Lib/test/test_import.py", line 167, in test_module_with_large_stack exec('import ' + module) File "", line 1, in File "/home/antoine/py3k/__svn__/Lib/importlib/_bootstrap.py", line 151, in decorated return fxn(self, module) File "/home/antoine/py3k/__svn__/Lib/importlib/_bootstrap.py", line 320, in load_module code_object = self.get_code(module.__name__) File "/home/antoine/py3k/__svn__/Lib/importlib/_bootstrap.py", line 429, in get_code "object for {0!r}".format(fullname)) ImportError: no source or bytecode available to create code object for 'longlist' test_heapq involves test.support.import_fresh_module().
msg105834 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2010-05-15 22:20
THe sys.path modification warning is a red herring; the test simply was not cleaning up after itself properly. That little bit is fixed in r81214. Don't know about the cause of the actual failure yet.
msg105836 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2010-05-15 22:50
I found the cause of the failure. When Barry implemented PEP 3147, he made PyPycLoader.bytecode_path() operate as if the only possible bytecode file one would want is the __cached__ one. That obviously is not accurate in the face of source-less modules. So the test_import is failing because it is not even attempting a bytecode-only import. What this means is that importlib needs to change its implementation of bytecode_path() to return the proper path based on whether the source exists. I will get to that hopefully this week. In the mean time I have flagged the test as an expected failure. This also shows me even more that I need to redo the ABCs in importlib to essentially make bytecode an optimization that the ABC handles and that is not exposed to the importer implementer.
msg105905 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2010-05-17 14:49
I cannot reproduce this on Ubuntu 10.04 with current py3k (r81268), even using the boiled down example given by Antoine. What platform are you on?
msg105939 - (view) Author: Alyssa Coghlan (ncoghlan) * (Python committer) Date: 2010-05-17 21:14
Brett marked it as an expected failure in r81219. Probably should have mentioned that here at the time though...
msg105944 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2010-05-17 23:11
Sorry about that. I guess I should have been more explicit when I said that "I have flagged the test as an expected failure" that meant I made it pass in the test suite until I get a chance to fix this.
msg105965 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2010-05-18 10:51
Thanks, Antoine filled me in on IRC just before my 'net connection went down for many hours. The good news is that I have a fix for this and will commit it in a little while.
msg105978 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2010-05-18 14:15
r81290
History
Date User Action Args
2022-04-11 14:57:01 admin set github: 52973
2010-05-18 14:15:40 barry set status: open -> closedassignee: brett.cannon -> barryresolution: fixedmessages: +
2010-05-18 10:51:10 barry set messages: +
2010-05-17 23:11:08 brett.cannon set messages: +
2010-05-17 21:14:17 ncoghlan set messages: +
2010-05-17 14:49:33 barry set messages: +
2010-05-15 22:52:58 brett.cannon set priority: normal -> critical
2010-05-15 22:50:49 brett.cannon set assignee: brett.cannonmessages: +
2010-05-15 22:20:42 brett.cannon set messages: +
2010-05-15 21:43:50 pitrou set nosy: + barry, brett.cannon, ncoghlanmessages: + stage: needs patch
2010-05-15 21:10:59 pitrou create