_reduce():
- Fix for SF bug #482752: __getstate__ & __setstate__ ignored (by Anon.) In fact, only __getstate__ isn't recognized. This fixes that. - Separately, the test for base.__flags__ & _HEAPTYPE raised an AttributeError exception when a classic class was amongst the bases. Fixed this with a hasattr() bandaid (classic classes never qualify as the "hard" base class anyway, which is what the code is trying to find).
This commit is contained in:
parent
64585f6afb
commit
00fb0c954f
|
@ -46,7 +46,7 @@ _HEAPTYPE = 1<<9
|
|||
|
||||
def _reduce(self):
|
||||
for base in self.__class__.__mro__:
|
||||
if not base.__flags__ & _HEAPTYPE:
|
||||
if hasattr(base, '__flags__') and not base.__flags__ & _HEAPTYPE:
|
||||
break
|
||||
else:
|
||||
base = object # not really reachable
|
||||
|
@ -55,10 +55,15 @@ def _reduce(self):
|
|||
else:
|
||||
state = base(self)
|
||||
args = (self.__class__, base, state)
|
||||
try:
|
||||
getstate = self.__getstate__
|
||||
except AttributeError:
|
||||
try:
|
||||
dict = self.__dict__
|
||||
except AttributeError:
|
||||
dict = None
|
||||
else:
|
||||
dict = getstate()
|
||||
if dict:
|
||||
return _reconstructor, args, dict
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue