summaryrefslogtreecommitdiffstats
path: root/Lib/pickle.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1997-09-08 02:08:11 (GMT)
committerGuido van Rossum <guido@python.org>1997-09-08 02:08:11 (GMT)
commitd6ead328b36eb686b95dd9949087dc77a6ff0234 (patch)
tree8a182a11855e4ca542ae6189236b25ebc20c8660 /Lib/pickle.py
parent75626a3b934f27b7bc19901997131561e35edc9a (diff)
downloadcpython-d6ead328b36eb686b95dd9949087dc77a6ff0234.zip
cpython-d6ead328b36eb686b95dd9949087dc77a6ff0234.tar.gz
cpython-d6ead328b36eb686b95dd9949087dc77a6ff0234.tar.bz2
*Semantic change*: when unpickling the instance variables of an
instance, use inst.__dict__.update(value) instead of a for loop with setattr() over the value.keys(). This is more consistent (the pickling doesn't use getattr() either but pickles inst.__dict__) and avoids problems with instances that have a __setattr__ hook. But it *is* a semantic change (because the setattr hook is no longer used). So beware!
Diffstat (limited to 'Lib/pickle.py')
-rw-r--r--Lib/pickle.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py
index 97eb4e4..7458792 100644
--- a/Lib/pickle.py
+++ b/Lib/pickle.py
@@ -843,8 +843,7 @@ class Unpickler:
try:
setstate = inst.__setstate__
except AttributeError:
- for key in value.keys():
- setattr(inst, key, value[key])
+ inst.__dict__.update(value)
else:
setstate(value)
dispatch[BUILD] = load_build