M
Matthew Brett
Hi,
I recently ran into this behavior:
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
I recently ran into this behavior:
Traceback (most recent call last):import sys
import apkg.subpkg
del sys.modules['apkg']
import apkg.subpkg as subpkg
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