[Python-Dev] Is this a bug?

Josiah Carlson jcarlson at uci.edu
Thu Aug 10 08:41:07 CEST 2006


"Neal Norwitz" <nnorwitz at gmail.com> wrote:
> 
> On 8/9/06, Josiah Carlson <jcarlson at uci.edu> wrote:
> > 2.4 performed these imports silently, while 2.5 complains "SystemError:
> > Parent module 'x' not loaded", which is actually a useful message, and
> > helped me fix it.
> 
> Can you make a small, self-contained test case?  The SystemError
> should be a normal exception and might indicate a deeper problem.


Create a module z.py whose contents are:

#z.py
import sys
import imp

sys.stdout = None
try:
    y = imp.load_source('x.y', 'x/y.py', open('x/y.py'))
except:
    raise
else:
    print "printing should raise an AttributeError, but doesn't"

#end of listing for z.py

Create a module x/y.py whose contents are: (x/__init__.py not required)

#x/y.py
import sys

#end of listing for x/y.py


Running z.py in Python 2.3 and 2.4 produces:
    printing should raise an AttributeError, but doesn't

Running z.py in Python 2.5b2 produces:
    Traceback (most recent call last):
      File "test.py", line 7, in <module>
        y = imp.load_source('x.y', 'x/y.py', open('x/y.py'))
      File "x/y.py", line 1, in <module>
        import sys
    SystemError: Parent module 'x' not loaded


 - Josiah



More information about the Python-Dev mailing list