[Python-checkins] CVS: python/dist/src/Lib pickle.py,1.55,1.56
Guido van Rossum
gvanrossum@users.sourceforge.net
2001年12月19日 08:55:07 -0800
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv11580
Modified Files:
pickle.py
Log Message:
Pickler.save(): Fix for SF bug #494904: Cannot pickle a class with a
metaclass, reported by Dan Parisien.
Objects that are instances of custom metaclasses, i.e. whose class is
a subclass of 'type', should be pickled the same as new-style classes
(objects whose class is 'type'). This can't be done through a
dispatch table entry, and the __reduce__ trick doesn't work for these,
since it finds the unbound __reduce__ for instances of the class
(inherited from 'object'). So check explicitly using issubclass().
Index: pickle.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/pickle.py,v
retrieving revision 1.55
retrieving revision 1.56
diff -C2 -d -r1.55 -r1.56
*** pickle.py 2001年11月15日 23:42:58 1.55
--- pickle.py 2001年12月19日 16:55:02 1.56
***************
*** 164,167 ****
--- 164,171 ----
f = self.dispatch[t]
except KeyError:
+ if issubclass(t, TypeType):
+ self.save_global(object)
+ return
+
pid = self.inst_persistent_id(object)
if pid is not None: