[issue3221] SystemError: Parent module 'foo' not loaded on import statement

Ralf Schmitt report at bugs.python.org
Fri Jun 27 22:35:29 CEST 2008


New submission from Ralf Schmitt <schmir at gmail.com>:

The following short program work in python 2.5, but does die with a
SystemError in python2.6:

~/ cat t.py 
#! /usr/bin/env python

res = dict(__package__='foo')
exec "from os import path" in res
~/ python2.5 t.py 
~/ python2.6 t.py 
Traceback (most recent call last):
  File "t.py", line 4, in <module>
exec "from os import path" in res
  File "<string>", line 1, in <module>
SystemError: Parent module 'foo' not loaded



I think this has been introduced with svn revision 42649
(http://hgpy.de/py/trunk/rev/54c72e1678d68ebbf274)

Part of the diff reads:
        modules = PyImport_GetModuleDict();
        parent = PyDict_GetItemString(modules, buf);
        if (parent == NULL)
-               parent = Py_None;
+               PyErr_Format(PyExc_SystemError,
+                               "Parent module '%.200s' not loaded", buf);
        return parent;
        /* We expect, but can't guarantee, if parent != None, that:

----------
messages: 68850
nosy: schmir
severity: normal
status: open
title: SystemError: Parent module 'foo' not loaded on import statement
type: behavior
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3221>
_______________________________________


More information about the Python-bugs-list mailing list