[Python-checkins] CVS: python/dist/src/Lib copy_reg.py,1.8,1.9
Guido van Rossum
gvanrossum@users.sourceforge.net
Sat, 24 Nov 2001 13:04:33 -0800
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv15720
Modified Files:
copy_reg.py
Log Message:
_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).
Index: copy_reg.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/copy_reg.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** copy_reg.py 2001/09/28 18:13:29 1.8
--- copy_reg.py 2001/11/24 21:04:31 1.9
***************
*** 47,51 ****
def _reduce(self):
for base in self.__class__.__mro__:
! if not base.__flags__ & _HEAPTYPE:
break
else:
--- 47,51 ----
def _reduce(self):
for base in self.__class__.__mro__:
! if hasattr(base, '__flags__') and not base.__flags__ & _HEAPTYPE:
break
else:
***************
*** 57,63 ****
args = (self.__class__, base, state)
try:
! dict = self.__dict__
except AttributeError:
! dict = None
if dict:
return _reconstructor, args, dict
--- 57,68 ----
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