mirror of
https://github.com/python/cpython.git
synced 2024-11-26 11:24:40 +08:00
_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:
parent
d48004f4f0
commit
698acf98fd
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user