Message139542
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. |
|
Date |
User |
Action |
Args |
2011-07-01 05:25:40 | pwil3058 | set | recipients:
+ pwil3058 |
2011-07-01 05:25:40 | pwil3058 | set | messageid: <1309497940.68.0.603392922196.issue12457@psf.upfronthosting.co.za> |
2011-07-01 05:25:40 | pwil3058 | link | issue12457 messages |
2011-07-01 05:25:39 | pwil3058 | create | |
|