summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2013-05-03 09:24:15 (GMT)
committerRaymond Hettinger <python@rcn.com>2013-05-03 09:24:15 (GMT)
commitb98dcc1f5307789c3c42af701f81147e240b90ff (patch)
tree48af503a1d85a5fe05b75d5e49be258f69fb449d
parent8e596a765cf323cbd2ba31b15f2939f903d87913 (diff)
downloadcpython-b98dcc1f5307789c3c42af701f81147e240b90ff.zip
cpython-b98dcc1f5307789c3c42af701f81147e240b90ff.tar.gz
cpython-b98dcc1f5307789c3c42af701f81147e240b90ff.tar.bz2
Issue #15535: Fix pickling of named tuples.
-rw-r--r--Lib/collections/__init__.py4
-rw-r--r--Lib/test/test_collections.py1
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS3
4 files changed, 9 insertions, 0 deletions
diff --git a/Lib/collections/__init__.py b/Lib/collections/__init__.py
index 707c53b..9f55a3e 100644
--- a/Lib/collections/__init__.py
+++ b/Lib/collections/__init__.py
@@ -281,6 +281,10 @@ class {typename}(tuple):
'Return self as a plain tuple. Used by copy and pickle.'
return tuple(self)
+ def __getstate__(self):
+ 'Exclude the OrderedDict from pickling'
+ return None
+
{field_defs}
'''
diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py
index 8850e8b..af27d22 100644
--- a/Lib/test/test_collections.py
+++ b/Lib/test/test_collections.py
@@ -273,6 +273,7 @@ class TestNamedTuple(unittest.TestCase):
q = loads(dumps(p, protocol))
self.assertEqual(p, q)
self.assertEqual(p._fields, q._fields)
+ self.assertNotIn(b'OrderedDict', dumps(p, protocol))
def test_copy(self):
p = TestNT(x=10, y=20, z=30)
diff --git a/Misc/ACKS b/Misc/ACKS
index 3b0630a..6a0d16f 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -811,6 +811,7 @@ Trent Mick
Jason Michalski
Franck Michea
Tom Middleton
+Thomas Miedema
Stan Mihai
Stefan Mihaila
Aristotelis Mikropoulos
diff --git a/Misc/NEWS b/Misc/NEWS
index 465ca10..db0c594 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -47,6 +47,9 @@ Library
- Issue #17802: Fix an UnboundLocalError in html.parser. Initial tests by
Thomas Barlow.
+- Issue #15535: Fix namedtuple pickles which were picking up the OrderedDict
+ instead of just the underlying tuple.
+
- Issue #17192: Restore the patch for Issue #11729 which was ommitted in
3.3.1 when updating the bundled version of libffi used by ctypes. Update
many libffi files that were missed in 3.3.1's update to libffi-3.0.13.