]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
*Semantic change*: when unpickling the instance variables of an
authorGuido van Rossum <guido@python.org>
Mon, 8 Sep 1997 02:08:11 +0000 (02:08 +0000)
committerGuido van Rossum <guido@python.org>
Mon, 8 Sep 1997 02:08:11 +0000 (02:08 +0000)
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!

Lib/pickle.py

index 97eb4e45bc8def715cc7756f7cc22b78c04bd873..7458792cdccc492eabfcb1c1fffb15fb36dc3ae7 100644 (file)
@@ -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