Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f76d22f8
Commit
f76d22f8
authored
May 03, 2013
by
Raymond Hettinger
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #15535: Fix regression in pickling of named tuples.
parent
da1c5d95
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
6 deletions
+5
-6
Doc/library/collections.rst
Doc/library/collections.rst
+1
-3
Lib/collections.py
Lib/collections.py
+0
-2
Lib/test/test_collections.py
Lib/test/test_collections.py
+1
-1
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Doc/library/collections.rst
View file @
f76d22f8
...
...
@@ -628,9 +628,7 @@ Example:
'Return a new OrderedDict which maps field names to their values'
return OrderedDict(zip(self._fields, self))
<BLANKLINE>
__dict__ = property(_asdict)
<BLANKLINE>
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:
...
...
Lib/collections.py
View file @
f76d22f8
...
...
@@ -259,8 +259,6 @@ class {typename}(tuple):
'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))
...
...
Lib/test/test_collections.py
View file @
f76d22f8
...
...
@@ -78,12 +78,12 @@ class TestNamedTuple(unittest.TestCase):
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
)
...
...
Misc/NEWS
View file @
f76d22f8
...
...
@@ -17,6 +17,9 @@ Build
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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment