Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

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

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Jun 27, 2008, 2:02 PM

Post #1 of 8 (188 views)
Permalink
[issue3221] SystemError: Parent module 'foo' not loaded on import statement

Changes by Benjamin Peterson <musiccomposition[at]gmail.com>:


----------
assignee: -> twouters
nosy: +twouters

_______________________________________
Python tracker <report[at]bugs.python.org>
<http://bugs.python.org/issue3221>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jun 27, 2008, 1:35 PM

Post #2 of 8 (188 views)
Permalink
[issue3221] SystemError: Parent module 'foo' not loaded on import statement [In reply to]

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>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 4, 2008, 5:40 PM

Post #3 of 8 (168 views)
Permalink
[issue3221] SystemError: Parent module 'foo' not loaded on import statement [In reply to]

Nick Coghlan <ncoghlan[at]gmail.com> added the comment:

Hmm, setting an invalid value for __package__ will definitely break
relative imports (see PEP 361), but it probably shouldn't be breaking
absolute imports.

----------
nosy: +ncoghlan

_______________________________________
Python tracker <report[at]bugs.python.org>
<http://bugs.python.org/issue3221>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 4, 2008, 5:54 PM

Post #4 of 8 (169 views)
Permalink
[issue3221] SystemError: Parent module 'foo' not loaded on import statement [In reply to]

Nick Coghlan <ncoghlan[at]gmail.com> added the comment:

One idea would be to change the import code to only produce a warning
for a missing __package__ entry instead of a SystemError (reserving the
SystemError for cases where the package name is derived from __name__
rather than being retrieved from the __package__ attribute).

_______________________________________
Python tracker <report[at]bugs.python.org>
<http://bugs.python.org/issue3221>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 7, 2008, 5:49 AM

Post #5 of 8 (157 views)
Permalink
[issue3221] SystemError: Parent module 'foo' not loaded on import statement [In reply to]

Nick Coghlan <ncoghlan[at]gmail.com> added the comment:

Bumped priority - an existing module shouldn't crash in 2.6 just because
we started using __package__ as part of the import mechanism and that
module happens to already set an attribute by that name.

----------
priority: -> release blocker

_______________________________________
Python tracker <report[at]bugs.python.org>
<http://bugs.python.org/issue3221>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 7, 2008, 5:54 AM

Post #6 of 8 (156 views)
Permalink
[issue3221] SystemError: Parent module 'foo' not loaded on import statement [In reply to]

Nick Coghlan <ncoghlan[at]gmail.com> added the comment:

Adding to my personal to-do list for next beta.

----------
assignee: twouters -> ncoghlan

_______________________________________
Python tracker <report[at]bugs.python.org>
<http://bugs.python.org/issue3221>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 13, 2008, 8:08 AM

Post #7 of 8 (143 views)
Permalink
[issue3221] SystemError: Parent module 'foo' not loaded on import statement [In reply to]

Nick Coghlan <ncoghlan[at]gmail.com> added the comment:

Fixed in r64915.

The end result is that the import system now only emits a RuntimeWarning
instead of raising SystemError if it can't find the parent module when
attempting to perform an absolute import (regardless of whether the
parent module name was derived from __package__ or from __name__).
Explicit relative imports will still fail if __package__ is set
incorrectly and setting __package__ to a non-string value will still
result in a ValueError.

----------
assignee: ncoghlan ->
resolution: -> fixed
status: open -> closed

_______________________________________
Python tracker <report[at]bugs.python.org>
<http://bugs.python.org/issue3221>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Jul 13, 2008, 2:07 PM

Post #8 of 8 (138 views)
Permalink
[issue3221] SystemError: Parent module 'foo' not loaded on import statement [In reply to]

Ralf Schmitt <schmir[at]gmail.com> added the comment:

Thanks Nick for fixing this in a timely manner.
BTW I've seen this when trying to run doctests with py.test.

_______________________________________
Python tracker <report[at]bugs.python.org>
<http://bugs.python.org/issue3221>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.