[ python-Bugs-1731068 ] Importing a submodule fails after unloading its parent

SourceForge.net noreply at sourceforge.net
Mon Jun 11 01:45:36 CEST 2007


Bugs item #1731068, was opened at 2007-06-04 20:21
Message generated for change (Comment added) made by gagenellina
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1731068&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Blake Ross (blakeross)
Assigned to: Nobody/Anonymous (nobody)
Summary: Importing a submodule fails after unloading its parent

Initial Comment:
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'
>>>

----------------------------------------------------------------------

Comment By: Gabriel Genellina (gagenellina)
Date: 2007-06-10 20:45

Message:
Logged In: YES 
user_id=479790
Originator: NO

The same example works OK for me on 2.5.1 on Windows.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1731068&group_id=5470


More information about the Python-bugs-list mailing list