diff options
author | Guido van Rossum <guido@python.org> | 2001-11-24 21:04:31 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-11-24 21:04:31 (GMT) |
commit | 00fb0c954faeb582ab5a4b1776b774686509e3d3 (patch) | |
tree | d722d66d90e61b3746fc5e55cd3a09f00463a8c1 /Lib | |
parent | 64585f6afb33ea907a22a365b4fdbec155e3da55 (diff) | |
download | cpython-00fb0c954faeb582ab5a4b1776b774686509e3d3.zip cpython-00fb0c954faeb582ab5a4b1776b774686509e3d3.tar.gz cpython-00fb0c954faeb582ab5a4b1776b774686509e3d3.tar.bz2 |
_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).
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/copy_reg.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/copy_reg.py b/Lib/copy_reg.py index d469744..92cbd53 100644 --- a/Lib/copy_reg.py +++ b/Lib/copy_reg.py @@ -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 @@ -56,9 +56,14 @@ def _reduce(self): state = base(self) args = (self.__class__, base, state) try: - dict = self.__dict__ + getstate = self.__getstate__ except AttributeError: - dict = None + try: + dict = self.__dict__ + except AttributeError: + dict = None + else: + dict = getstate() if dict: return _reconstructor, args, dict else: |