Message252753
The load_module() API adds an entry to sys.modules when loading a submodule, but does not add the submodule as an attribute in the parent package. I am no expert on PEP 302 or the import system, but this feels like a bug to me:
>>> import sys, pkgutil
>>> loader = pkgutil.find_loader("xml.etree")
>>> loader.load_module("xml.etree")
<module 'xml.etree' from '/usr/lib/python3.4/xml/etree/__init__.py'>
>>> sys.modules["xml.etree"] # Entry added, per documentation and PEP 302
<module 'xml.etree' from '/usr/lib/python3.4/xml/etree/__init__.py'>
>>> hasattr(sys.modules["xml"], "etree") # But not linked to parent!
False
>>> import xml.etree
>>> xml.etree # Broken :(
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'etree' |
|
Date |
User |
Action |
Args |
2015-10-11 02:47:12 | martin.panter | set | recipients:
+ martin.panter |
2015-10-11 02:47:12 | martin.panter | set | messageid: <1444531632.83.0.513711320874.issue25372@psf.upfronthosting.co.za> |
2015-10-11 02:47:12 | martin.panter | link | issue25372 messages |
2015-10-11 02:47:10 | martin.panter | create | |
|