mirror of
https://github.com/python/cpython.git
synced 2025-11-13 15:40:05 +00:00
Issue #15535: Fix pickling of named tuples.
This commit is contained in:
parent
a6df938fef
commit
ce654f48aa
3 changed files with 8 additions and 0 deletions
|
|
@ -281,6 +281,10 @@ class {typename}(tuple):
|
||||||
'Return self as a plain tuple. Used by copy and pickle.'
|
'Return self as a plain tuple. Used by copy and pickle.'
|
||||||
return tuple(self)
|
return tuple(self)
|
||||||
|
|
||||||
|
def __getstate__(self):
|
||||||
|
'Exclude the OrderedDict from pickling'
|
||||||
|
return None
|
||||||
|
|
||||||
{field_defs}
|
{field_defs}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -272,6 +272,7 @@ class TestNamedTuple(unittest.TestCase):
|
||||||
q = loads(dumps(p, protocol))
|
q = loads(dumps(p, protocol))
|
||||||
self.assertEqual(p, q)
|
self.assertEqual(p, q)
|
||||||
self.assertEqual(p._fields, q._fields)
|
self.assertEqual(p._fields, q._fields)
|
||||||
|
self.assertNotIn(b'OrderedDict', dumps(p, protocol))
|
||||||
|
|
||||||
def test_copy(self):
|
def test_copy(self):
|
||||||
p = TestNT(x=10, y=20, z=30)
|
p = TestNT(x=10, y=20, z=30)
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,9 @@ Library
|
||||||
|
|
||||||
- Issue #17666: Fix reading gzip files with an extra field.
|
- Issue #17666: Fix reading gzip files with an extra field.
|
||||||
|
|
||||||
|
- Issue #15535: Fix namedtuple pickles which were picking up the OrderedDict
|
||||||
|
instead of just the underlying tuple.
|
||||||
|
|
||||||
|
|
||||||
What's New in Python 3.2.4?
|
What's New in Python 3.2.4?
|
||||||
===========================
|
===========================
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue