New submission from Mario Juric mju...@ias.edu:
The implementation of OrderedDict.__reduce__() in Python 2.7.1 is not thread
safe because of the following four lines:
tmp = self.__map, self.__root
del self.__map, self.__root
inst_dict = vars(self).copy()
Changes by Raymond Hettinger raymond.hettin...@gmail.com:
--
assignee: - rhettinger
nosy: +rhettinger
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11875
___
Raymond Hettinger raymond.hettin...@gmail.com added the comment:
To avoid hardcoding the mangled names:
@@ -155,10 +155,9 @@
def __reduce__(self):
'Return state information for pickling'
items = [[k, self[k]] for k in self]
-tmp = self.__map, self.__root,
Roundup Robot devnull@devnull added the comment:
New changeset 3150b6939731 by Raymond Hettinger in branch '2.7':
Issue 11875: Keep OrderedDict's __reduce__ from temporarily mutating the object.
http://hg.python.org/cpython/rev/3150b6939731
--
nosy: +python-dev
Roundup Robot devnull@devnull added the comment:
New changeset 50a89739836f by Raymond Hettinger in branch '3.1':
Issue 11875: Keep OrderedDict's __reduce__ from temporarily mutating the object.
http://hg.python.org/cpython/rev/50a89739836f
New changeset a7ac7a7c8c78 by Raymond Hettinger in
Raymond Hettinger raymond.hettin...@gmail.com added the comment:
Mario, I removed the unnecessary mutation, but remember that OrderedDict's are
not thread-safe in general. Anything that updates an OrderedDict will
temporarily leave it in an inconsistent state while the links and mappings are
Mario Juric mju...@ias.edu added the comment:
Hi Raymond,
Excellent! Many thanks for such a quick fix, this has been bugging us for
months!
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11875
Amaury Forgeot d'Arc amaur...@gmail.com added the comment:
The call to self.__class__() can break subclasses of OrderedDict for two
reasons:
- The subclass constructor may have a different signature
- Attributes set by the subclass.__init__ are removed from the pickle::
import collections,
Changes by Daniel Urban urban.dani...@gmail.com:
--
nosy: +durban
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11875
___
___
Python-bugs-list
Roundup Robot devnull@devnull added the comment:
New changeset db66eaf353a6 by Raymond Hettinger in branch '2.7':
Issue #11875: Alter the previous fix to work better with subclasses
http://hg.python.org/cpython/rev/db66eaf353a6
--
___
Python tracker
Roundup Robot devnull@devnull added the comment:
New changeset 408f23b6cec5 by Raymond Hettinger in branch '3.1':
Issue #11875: Alter the previous fix to work better with subclasses
http://hg.python.org/cpython/rev/408f23b6cec5
New changeset 4e6840477d96 by Raymond Hettinger in branch '3.2':
11 matches
Mail list logo