diff options
author | Guido van Rossum <guido@python.org> | 2001-11-24 21:04:31 +0000 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-11-24 21:04:31 +0000 |
commit | 7807d9303ec2b96c88b2da91b650d335ff5ed810 (patch) | |
tree | 99acfa80fef73c1978bbfd82cd26283ef80b26c0 /Lib/copy_reg.py | |
parent | f1748496b701f15575dc24c08b2241063716203c (diff) | |
download | cpython-7807d9303ec2b96c88b2da91b650d335ff5ed810.tar.gz |
_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/copy_reg.py')
-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 d4697449a0..92cbd5345b 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: |