]> granicus.if.org Git - python/commitdiff
Fix from SF patch 565085: copy._reduction doesn't __setstate__.
authorGuido van Rossum <guido@python.org>
Thu, 6 Jun 2002 17:41:20 +0000 (17:41 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 6 Jun 2002 17:41:20 +0000 (17:41 +0000)
Straightforward fix.  Will backport to 2.2.  If there's ever a new 2.1
release, this could be backported there too (since it's an issue with
anything that's got both a __reduce__ and a __setstate__).

Lib/copy.py

index 01805549ab3b948b455652d35b4646c948af2ab2..77b7ad3a005de12f2963ecf53976166e493fc9fd 100644 (file)
@@ -301,7 +301,10 @@ def _reconstruct(x, info, deep, memo=None):
     if state:
         if deep:
             state = deepcopy(state, memo)
-        y.__dict__.update(state)
+        if hasattr(y, '__setstate__'):
+            y.__setstate__(state)
+        else:
+            y.__dict__.update(state)
     return y
 
 del d