New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SystemError: Parent module 'foo' not loaded on import statement #47471
Comments
The following short program work in python 2.5, but does die with a ~/ cat t.py 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 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: |
Hmm, setting an invalid value for __package__ will definitely break |
One idea would be to change the import code to only produce a warning |
Bumped priority - an existing module shouldn't crash in 2.6 just because |
Adding to my personal to-do list for next beta. |
Fixed in r64915. The end result is that the import system now only emits a RuntimeWarning |
Thanks Nick for fixing this in a timely manner. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: