[Python-bugs-list] [ python-Bugs-658693 ] cPickle does relative import

noreply@sourceforge.net noreply@sourceforge.net
Thu, 26 Dec 2002 07:23:39 -0800


Bugs item #658693, was opened at 2002-12-26 10:23
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=658693&group_id=5470

Category: Extension Modules
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Guido van Rossum (gvanrossum)
Assigned to: Nobody/Anonymous (nobody)
Summary: cPickle does relative import

Initial Comment:
save_global() in cPickle calls PyImport_ImportModule()
to import the module of a global that's about to be
pickled, in order to check whether the given name in
fact refers to the given object.

But when it is invoked from code living inside a
package, PyImport_ImportModule() first tries a relative
import, and if by sheer accident that relative import
succeeds, it performs the wrong test.

Example: in a package that has a submodule
"exceptions", pickling instances of built-in exceptions
will attempt to look up the exception class name in the
exceptions submodule rather than in the built-in
toplevel module by that name.

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

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