Commit ebfecfde authored by Alexandre Vassalotti's avatar Alexandre Vassalotti

Only try to intern str objects when unpickling attributes.

This matches the behaviour implmented in _pickle.
parent f70b129d
...@@ -1195,15 +1195,13 @@ class _Unpickler: ...@@ -1195,15 +1195,13 @@ class _Unpickler:
if isinstance(state, tuple) and len(state) == 2: if isinstance(state, tuple) and len(state) == 2:
state, slotstate = state state, slotstate = state
if state: if state:
d = inst.__dict__ inst_dict = inst.__dict__
intern = sys.intern intern = sys.intern
try:
for k, v in state.items(): for k, v in state.items():
d[intern(k)] = v if type(k) is str:
# keys in state don't have to be strings inst_dict[intern(k)] = v
# don't blow up, but don't go out of our way else:
except TypeError: inst_dict[k] = v
d.update(state)
if slotstate: if slotstate:
for k, v in slotstate.items(): for k, v in slotstate.items():
setattr(inst, k, v) setattr(inst, k, v)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment