Author ncoghlan
Recipients Arfrever, brett.cannon, eric.snow, ncoghlan, pje
Date 2013-10-31.11:53:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Failing test case showing that Python 3.3 can't reload a module that is converted to a package behind importlib's back (I like this better than the purely introspection based tests, since it shows a real, albeit obscure, regression due to this behavioural change):

$ ./ 
ERROR: test_module_to_package (__main__.TestBadReload)
Traceback (most recent call last):
  File "./", line 28, in test_module_to_package
  File "/usr/lib64/python3.3/", line 271, in reload
    return module.__loader__.load_module(name)
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1024, in load_module
  File "<frozen importlib._bootstrap>", line 1005, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 855, in _load_module
  File "<frozen importlib._bootstrap>", line 950, in get_code
  File "<frozen importlib._bootstrap>", line 1043, in path_stats
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp_n48mm/'

Ran 1 test in 0.002s

FAILED (errors=1)

Interactive session showing that import.c didn't have this problem, since it reran the whole search (foo is just a toy module I had lying around in my play directory):

$ python
Python 2.7.5 (default, Oct  8 2013, 12:19:40) 
[GCC 4.8.1 20130603 (Red Hat 4.8.1-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import foo
>>> foo.__file__
>>> import os
>>> os.mkdir("foo")
>>> os.rename('', 'foo/')
>>> reload(foo)
<module 'foo' from 'foo/'>
>>> foo.__file__
Date User Action Args
2013-10-31 11:53:39ncoghlansetrecipients: + ncoghlan, brett.cannon, pje, Arfrever, eric.snow
2013-10-31 11:53:39ncoghlansetmessageid: <>
2013-10-31 11:53:39ncoghlanlinkissue19413 messages
2013-10-31 11:53:38ncoghlancreate