Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3e3583c

Browse files
committed
Fix from SF patch 565085: copy._reduction doesn't __setstate__.
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__).
1 parent 88a20ba commit 3e3583c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

Lib/copy.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,10 @@ def _reconstruct(x, info, deep, memo=None):
301301
if state:
302302
if deep:
303303
state = deepcopy(state, memo)
304-
y.__dict__.update(state)
304+
if hasattr(y, '__setstate__'):
305+
y.__setstate__(state)
306+
else:
307+
y.__dict__.update(state)
305308
return y
306309

307310
del d

0 commit comments

Comments
 (0)