This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_import failure
Type: behavior Stage: needs patch
Components: Library (Lib), Tests Versions: Python 3.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: barry Nosy List: barry, brett.cannon, ncoghlan, pitrou
Priority: critical Keywords:

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 "<string>", line 1, in <module>
  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 "<string>", line 1, in <module>
  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: Nick 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:01adminsetgithub: 52973
2010-05-18 14:15:40barrysetstatus: open -> closed
assignee: brett.cannon -> barry
resolution: fixed
messages: + msg105978
2010-05-18 10:51:10barrysetmessages: + msg105965
2010-05-17 23:11:08brett.cannonsetmessages: + msg105944
2010-05-17 21:14:17ncoghlansetmessages: + msg105939
2010-05-17 14:49:33barrysetmessages: + msg105905
2010-05-15 22:52:58brett.cannonsetpriority: normal -> critical
2010-05-15 22:50:49brett.cannonsetassignee: brett.cannon
messages: + msg105836
2010-05-15 22:20:42brett.cannonsetmessages: + msg105834
2010-05-15 21:43:50pitrousetnosy: + barry, brett.cannon, ncoghlan

messages: + msg105829
stage: needs patch
2010-05-15 21:10:59pitroucreate