Kaydet (Commit) e0156c43 authored tarafından Raymond Hettinger's avatar Raymond Hettinger

Issue 11875: Keep OrderedDict's __reduce__ from temporarily mutating the object.

üst 0513275b
...@@ -115,10 +115,9 @@ class OrderedDict(dict): ...@@ -115,10 +115,9 @@ class OrderedDict(dict):
def __reduce__(self): def __reduce__(self):
'Return state information for pickling' 'Return state information for pickling'
items = [[k, self[k]] for k in self] items = [[k, self[k]] for k in self]
tmp = self.__map, self.__root
del self.__map, self.__root
inst_dict = vars(self).copy() inst_dict = vars(self).copy()
self.__map, self.__root = tmp for k in vars(OrderedDict()):
inst_dict.pop(k, None)
if inst_dict: if inst_dict:
return (self.__class__, (items,), inst_dict) return (self.__class__, (items,), inst_dict)
return self.__class__, (items,) return self.__class__, (items,)
......
...@@ -59,6 +59,9 @@ Library ...@@ -59,6 +59,9 @@ Library
Py_AddPendingCall() for the first signal to fix a deadlock on reentrant or Py_AddPendingCall() for the first signal to fix a deadlock on reentrant or
parallel calls. PyErr_SetInterrupt() writes also into the wake up file. parallel calls. PyErr_SetInterrupt() writes also into the wake up file.
- Issue #11875: collections.OrderedDict's __reduce__ was temporarily
mutating the object instead of just working on a copy.
- Issue #11442: Add a charset parameter to the Content-type in SimpleHTTPServer - Issue #11442: Add a charset parameter to the Content-type in SimpleHTTPServer
to avoid XSS attacks. to avoid XSS attacks.
......
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