_reconstructor(): there's no need for tricks with assignment to

__class__.  The __new__ protocol is up to this.  (Thanks to Tim for
pointing this out.)
This commit is contained in:
Guido van Rossum 2001-09-25 19:46:05 +00:00
parent d48004f4f0
commit 698acf98fd

View File

@ -36,16 +36,9 @@ pickle(type(1j), pickle_complex, complex)
# Support for picking new-style objects
_dummy_classes = {}
def _reconstructor(cls, base, state):
dummy = _dummy_classes.get(base)
if dummy is None:
class dummy(base): pass
_dummy_classes[base] = dummy
obj = dummy(state)
obj._foo = 1; del obj._foo # hack to create __dict__
obj.__class__ = cls
obj = base.__new__(cls, state)
base.__init__(obj, state)
return obj
_reconstructor.__safe_for_unpickling__ = 1