Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
7393c69d
Kaydet (Commit)
7393c69d
authored
May 27, 2013
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #18015: Fix unpickling of 2.7.3 and 2.7.4 namedtuples.
üst
16c52a33
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
1 deletion
+57
-1
collections.rst
Doc/library/collections.rst
+6
-0
collections.py
Lib/collections.py
+6
-0
test_collections.py
Lib/test/test_collections.py
+43
-1
NEWS
Misc/NEWS
+2
-0
No files found.
Doc/library/collections.rst
Dosyayı görüntüle @
7393c69d
...
@@ -638,6 +638,12 @@ Example:
...
@@ -638,6 +638,12 @@ Example:
def __getnewargs__(self):
def __getnewargs__(self):
'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)
<BLANKLINE>
__dict__ = _property(_asdict)
<BLANKLINE>
def __getstate__(self):
'Exclude the OrderedDict from pickling'
pass
<BLANKLINE>
<BLANKLINE>
x = _property(_itemgetter(0), doc='Alias for field number 0')
x = _property(_itemgetter(0), doc='Alias for field number 0')
<BLANKLINE>
<BLANKLINE>
...
...
Lib/collections.py
Dosyayı görüntüle @
7393c69d
...
@@ -270,6 +270,12 @@ class {typename}(tuple):
...
@@ -270,6 +270,12 @@ 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)
__dict__ = _property(_asdict)
def __getstate__(self):
'Exclude the OrderedDict from pickling'
pass
{field_defs}
{field_defs}
'''
'''
...
...
Lib/test/test_collections.py
Dosyayı görüntüle @
7393c69d
...
@@ -17,6 +17,43 @@ from collections import Sequence, MutableSequence
...
@@ -17,6 +17,43 @@ from collections import Sequence, MutableSequence
TestNT
=
namedtuple
(
'TestNT'
,
'x y z'
)
# type used for pickle tests
TestNT
=
namedtuple
(
'TestNT'
,
'x y z'
)
# type used for pickle tests
py273_named_tuple_pickle
=
'''
\
ccopy_reg
_reconstructor
p0
(ctest.test_collections
TestNT
p1
c__builtin__
tuple
p2
(I10
I20
I30
tp3
tp4
Rp5
ccollections
OrderedDict
p6
((lp7
(lp8
S'x'
p9
aI10
aa(lp10
S'y'
p11
aI20
aa(lp12
S'z'
p13
aI30
aatp14
Rp15
b.
'''
class
TestNamedTuple
(
unittest
.
TestCase
):
class
TestNamedTuple
(
unittest
.
TestCase
):
def
test_factory
(
self
):
def
test_factory
(
self
):
...
@@ -78,12 +115,12 @@ class TestNamedTuple(unittest.TestCase):
...
@@ -78,12 +115,12 @@ class TestNamedTuple(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
eval
,
'Point(XXX=1, y=2)'
,
locals
())
# wrong keyword argument
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
.
assertRaises
(
TypeError
,
eval
,
'Point(x=1)'
,
locals
())
# missing keyword argument
self
.
assertEqual
(
repr
(
p
),
'Point(x=11, y=22)'
)
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
.
assertNotIn
(
'__weakref__'
,
dir
(
p
))
self
.
assertEqual
(
p
,
Point
.
_make
([
11
,
22
]))
# test _make classmethod
self
.
assertEqual
(
p
,
Point
.
_make
([
11
,
22
]))
# test _make classmethod
self
.
assertEqual
(
p
.
_fields
,
(
'x'
,
'y'
))
# test _fields attribute
self
.
assertEqual
(
p
.
_fields
,
(
'x'
,
'y'
))
# test _fields attribute
self
.
assertEqual
(
p
.
_replace
(
x
=
1
),
(
1
,
22
))
# test _replace method
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
(
p
.
_asdict
(),
dict
(
x
=
11
,
y
=
22
))
# test _asdict method
self
.
assertEqual
(
vars
(
p
),
p
.
_asdict
())
# verify that vars() works
try
:
try
:
p
.
_replace
(
x
=
1
,
error
=
2
)
p
.
_replace
(
x
=
1
,
error
=
2
)
...
@@ -215,6 +252,11 @@ class TestNamedTuple(unittest.TestCase):
...
@@ -215,6 +252,11 @@ class TestNamedTuple(unittest.TestCase):
# test __getnewargs__
# test __getnewargs__
self
.
assertEqual
(
t
.
__getnewargs__
(),
values
)
self
.
assertEqual
(
t
.
__getnewargs__
(),
values
)
def
test_pickling_bug_18015
(
self
):
# http://bugs.python.org/issue18015
pt
=
pickle
.
loads
(
py273_named_tuple_pickle
)
self
.
assertEqual
(
pt
.
x
,
10
)
class
ABCTestCase
(
unittest
.
TestCase
):
class
ABCTestCase
(
unittest
.
TestCase
):
def
validate_abstract_methods
(
self
,
abc
,
*
names
):
def
validate_abstract_methods
(
self
,
abc
,
*
names
):
...
...
Misc/NEWS
Dosyayı görüntüle @
7393c69d
...
@@ -19,6 +19,8 @@ Library
...
@@ -19,6 +19,8 @@ Library
- Issue #17981: Closed socket on error in SysLogHandler.
- Issue #17981: Closed socket on error in SysLogHandler.
- Issue #18015: Fix unpickling of 2.7.3 and 2.7.4 namedtuples.
- Issue #17754: Make ctypes.util.find_library() independent of the locale.
- Issue #17754: Make ctypes.util.find_library() independent of the locale.
- Fix typos in the multiprocessing module.
- Fix typos in the multiprocessing module.
...
...
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