diff options
author | Alexandre Vassalotti <alexandre@peadrop.com> | 2009-05-25 18:50:33 (GMT) |
---|---|---|
committer | Alexandre Vassalotti <alexandre@peadrop.com> | 2009-05-25 18:50:33 (GMT) |
commit | ebfecfde8b14c968c41a22f8c81fe0ac7e8f57c1 (patch) | |
tree | fa81aeb61df857f558880692664718992451b5a7 /Lib/pickle.py | |
parent | f70b129d7ca75079b552c9a5ee1c75a873ea3420 (diff) | |
download | cpython-ebfecfde8b14c968c41a22f8c81fe0ac7e8f57c1.zip cpython-ebfecfde8b14c968c41a22f8c81fe0ac7e8f57c1.tar.gz cpython-ebfecfde8b14c968c41a22f8c81fe0ac7e8f57c1.tar.bz2 |
Only try to intern str objects when unpickling attributes.
This matches the behaviour implmented in _pickle.
Diffstat (limited to 'Lib/pickle.py')
-rw-r--r-- | Lib/pickle.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/Lib/pickle.py b/Lib/pickle.py index b94b305..720c1a0 100644 --- a/Lib/pickle.py +++ b/Lib/pickle.py @@ -1195,15 +1195,13 @@ class _Unpickler: if isinstance(state, tuple) and len(state) == 2: state, slotstate = state if state: - d = inst.__dict__ + inst_dict = inst.__dict__ intern = sys.intern - try: - for k, v in state.items(): - d[intern(k)] = v - # keys in state don't have to be strings - # don't blow up, but don't go out of our way - except TypeError: - d.update(state) + for k, v in state.items(): + if type(k) is str: + inst_dict[intern(k)] = v + else: + inst_dict[k] = v if slotstate: for k, v in slotstate.items(): setattr(inst, k, v) |