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
bb7c57c6
Kaydet (Commit)
bb7c57c6
authored
Kas 19, 2015
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #25472: In B[<type>], insert B in front of __bases__, to make the __dict__ descriptor work.
üst
6efc7e72
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
1 deletion
+31
-1
test_typing.py
Lib/test/test_typing.py
+30
-0
typing.py
Lib/typing.py
+1
-1
No files found.
Lib/test/test_typing.py
Dosyayı görüntüle @
bb7c57c6
from
collections
import
namedtuple
import
pickle
import
re
import
sys
from
unittest
import
TestCase
,
main
...
...
@@ -583,6 +584,35 @@ class GenericTests(TestCase):
self
.
assertEqual
(
repr
(
MySimpleMapping
),
__name__
+
'.'
+
'MySimpleMapping[~XK, ~XV]'
)
def
test_dict
(
self
):
T
=
TypeVar
(
'T'
)
class
B
(
Generic
[
T
]):
pass
b
=
B
()
b
.
foo
=
42
self
.
assertEqual
(
b
.
__dict__
,
{
'foo'
:
42
})
class
C
(
B
[
int
]):
pass
c
=
C
()
c
.
bar
=
'abc'
self
.
assertEqual
(
c
.
__dict__
,
{
'bar'
:
'abc'
})
def
test_pickle
(
self
):
T
=
TypeVar
(
'T'
)
class
B
(
Generic
[
T
]):
pass
global
C
# pickle wants to reference the class by name
class
C
(
B
[
int
]):
pass
c
=
C
()
c
.
foo
=
42
c
.
bar
=
'abc'
z
=
pickle
.
dumps
(
c
)
x
=
pickle
.
loads
(
z
)
self
.
assertEqual
(
x
.
foo
,
42
)
self
.
assertEqual
(
x
.
bar
,
'abc'
)
self
.
assertEqual
(
x
.
__dict__
,
{
'foo'
:
42
,
'bar'
:
'abc'
})
def
test_errors
(
self
):
with
self
.
assertRaises
(
TypeError
):
B
=
SimpleMapping
[
XK
,
Any
]
...
...
Lib/typing.py
Dosyayı görüntüle @
bb7c57c6
...
...
@@ -981,7 +981,7 @@ class GenericMeta(TypingMeta, abc.ABCMeta):
"Cannot substitute
%
s for
%
s in
%
s"
%
(
_type_repr
(
new
),
_type_repr
(
old
),
self
))
return
self
.
__class__
(
self
.
__name__
,
self
.
__bases__
,
return
self
.
__class__
(
self
.
__name__
,
(
self
,)
+
self
.
__bases__
,
dict
(
self
.
__dict__
),
parameters
=
params
,
origin
=
self
,
...
...
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