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
557d1eb0
Kaydet (Commit)
557d1eb0
authored
Kas 19, 2015
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #25665: Make NamedTuple picklable.
üst
05e3090e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
test_typing.py
Lib/test/test_typing.py
+8
-0
typing.py
Lib/typing.py
+5
-0
No files found.
Lib/test/test_typing.py
Dosyayı görüntüle @
557d1eb0
...
...
@@ -1163,6 +1163,14 @@ class NamedTupleTests(TestCase):
assert
Emp
.
_fields
==
(
'name'
,
'id'
)
assert
Emp
.
_field_types
==
dict
(
name
=
str
,
id
=
int
)
def
test_pickle
(
self
):
global
Emp
# pickle wants to reference the class by name
Emp
=
NamedTuple
(
'Emp'
,
[(
'name'
,
str
),
(
'id'
,
int
)])
jane
=
Emp
(
'jane'
,
37
)
z
=
pickle
.
dumps
(
jane
)
jane2
=
pickle
.
loads
(
z
)
assert
jane
==
jane2
class
IOTests
(
TestCase
):
...
...
Lib/typing.py
Dosyayı görüntüle @
557d1eb0
...
...
@@ -1479,6 +1479,11 @@ def NamedTuple(typename, fields):
fields
=
[(
n
,
t
)
for
n
,
t
in
fields
]
cls
=
collections
.
namedtuple
(
typename
,
[
n
for
n
,
t
in
fields
])
cls
.
_field_types
=
dict
(
fields
)
# Set the module to the caller's module (otherwise it'd be 'typing').
try
:
cls
.
__module__
=
sys
.
_getframe
(
1
)
.
f_globals
.
get
(
'__name__'
,
'__main__'
)
except
(
AttributeError
,
ValueError
):
pass
return
cls
...
...
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