Hi,

I recently ran into this behavior:

>>> import sys
>>> import apkg.subpkg
>>> del sys.modules['apkg']
>>> import apkg.subpkg as subpkg
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'subpkg'

where 'apkg' and 'subpkg' comprise empty __init__.py files to simplify the 
example.

It appears then, that importing a subpackage, then deleting the containing 
package from sys.modules, orphans the subpackage in an unfixable state. 

I ran into this because the nose testing framework does exactly this kind of 
thing when loading test modules, causing some very confusing errors and 
failures.

Is this behavior expected?

Best,

Matthew
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to