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: Importing a submodule fails after unloading its parent
Type: Stage:
Components: Interpreter Core Versions:
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: blakeross, christian.heimes, ggenellina
Priority: normal Keywords:

Created on 2007-06-04 23:21 by blakeross, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg32208 - (view) Author: Blake Ross (blakeross) Date: 2007-06-04 23:21
It seems that if you import a submodule, cause its parent package to be destroyed, then attempt to re-import the submodule, the parent package is properly re-imported but the submodule does not get set on it.

The session below demonstrates this. After the second xml.sax import, "xml" is the xml package module as expected, but xml.sax does not exist. I'm not familiar with all of the import semantics, but it seems odd to me that "foo.bar" could ever fail to exist right after an "import foo.bar".

Python 2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)] o
32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys, xml.sax
>>> del xml, sys.modules["xml"]
>>> import xml.sax
>>> xml.sax
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'sax'
>>>
msg32209 - (view) Author: Gabriel Genellina (ggenellina) Date: 2007-06-10 23:45
The same example works OK for me on 2.5.1 on Windows.
msg57780 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2007-11-23 09:17
Yes, it's fixed in Python 2.5 and newer.
History
Date User Action Args
2022-04-11 14:56:24adminsetgithub: 45038
2007-11-23 09:17:11christian.heimessetstatus: open -> closed
resolution: out of date
messages: + msg57780
nosy: + christian.heimes
2007-06-04 23:21:02blakerosscreate