This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pwil3058
Recipients pwil3058
Date 2011-07-01.05:25:39
SpamBayes Score 2.0061325e-10
Marked as misclassified No
Message-id <1309497940.68.0.603392922196.issue12457@psf.upfronthosting.co.za>
In-reply-to
Content
The built in type() function returns incorrect type names for nested classes which in turn causes pickle to crash when used with nested classes as it cannot find the nested class definitions from the using the string returned by type().

e.g. if I have an instance "inner" of class Inner which is defined inside (nested in) the class Outer:

type(inner) returns <class '__main__.Inner'> instead of <class '__main__.Outer.Inner'>

The isinstance() function, as expected, returns True for isinstance(inner, Outer.Inner) and raises a NameError exception for isinstance(inner, Inner).

However, isinstance(inner, type(inner)) returns True which indicates the core functionality is OK and this conforms to the fact that no problems were encountered until I tried to pickle an object containing nested classes.

My system is Fedora 15 x86_64 and Python versions are 2.7.1 and 3.2.

A short program illustrating the problem is attached.
History
Date User Action Args
2011-07-01 05:25:40pwil3058setrecipients: + pwil3058
2011-07-01 05:25:40pwil3058setmessageid: <1309497940.68.0.603392922196.issue12457@psf.upfronthosting.co.za>
2011-07-01 05:25:40pwil3058linkissue12457 messages
2011-07-01 05:25:39pwil3058create