(original) (raw)

changeset: 83591:18303391b981 branch: 2.7 parent: 83589:c3656dca65e7 user: Raymond Hettinger python@rcn.com date: Fri May 03 00:59:20 2013 -0700 files: Doc/library/collections.rst Lib/collections.py Lib/test/test_collections.py Misc/NEWS description: Issue #15535: Fix regression in pickling of named tuples. diff -r c3656dca65e7 -r 18303391b981 Doc/library/collections.rst --- a/Doc/library/collections.rst Thu May 02 05:50:21 2013 -0700 +++ b/Doc/library/collections.rst Fri May 03 00:59:20 2013 -0700 @@ -628,9 +628,7 @@ 'Return a new OrderedDict which maps field names to their values' return OrderedDict(zip(self._fields, self))- __dict__ = property(_asdict) - - def _replace(_self, **kwds): + def _replace(_self, **kwds): 'Return a new Point object replacing specified fields with new values' result = _self._make(map(kwds.pop, ('x', 'y'), _self)) if kwds: diff -r c3656dca65e7 -r 18303391b981 Lib/collections.py --- a/Lib/collections.py Thu May 02 05:50:21 2013 -0700 +++ b/Lib/collections.py Fri May 03 00:59:20 2013 -0700 @@ -259,8 +259,6 @@ 'Return a new OrderedDict which maps field names to their values' return OrderedDict(zip(self._fields, self)) - __dict__ = property(_asdict) - def _replace(_self, **kwds): 'Return a new {typename} object replacing specified fields with new values' result = _self._make(map(kwds.pop, {field_names!r}, _self)) diff -r c3656dca65e7 -r 18303391b981 Lib/test/test_collections.py --- a/Lib/test/test_collections.py Thu May 02 05:50:21 2013 -0700 +++ b/Lib/test/test_collections.py Fri May 03 00:59:20 2013 -0700 @@ -78,12 +78,12 @@ self.assertRaises(TypeError, eval, 'Point(XXX=1, y=2)', locals()) # wrong keyword argument self.assertRaises(TypeError, eval, 'Point(x=1)', locals()) # missing keyword argument self.assertEqual(repr(p), 'Point(x=11, y=22)') + self.assertNotIn('__dict__', dir(p)) # verify instance has no dict self.assertNotIn('__weakref__', dir(p)) self.assertEqual(p, Point._make([11, 22])) # test _make classmethod self.assertEqual(p._fields, ('x', 'y')) # test _fields attribute self.assertEqual(p._replace(x=1), (1, 22)) # test _replace method self.assertEqual(p._asdict(), dict(x=11, y=22)) # test _asdict method - self.assertEqual(vars(p), p._asdict()) # verify that vars() works try: p._replace(x=1, error=2) diff -r c3656dca65e7 -r 18303391b981 Misc/NEWS --- a/Misc/NEWS Thu May 02 05:50:21 2013 -0700 +++ b/Misc/NEWS Fri May 03 00:59:20 2013 -0700 @@ -17,6 +17,9 @@ Core and Builtins ----------------- +- Issue #15535: Fixed regression in the pickling of named tuples by + removing the __dict__ property introduced in 2.7.4. + - Issue #17857: Prevent build failures with pre-3.5.0 versions of sqlite3, such as was shipped with Centos 5 and Mac OS X 10.4./python@rcn.com