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
647bae6c
Kaydet (Commit)
647bae6c
authored
Eyl 04, 2015
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #24635: Fixed flakiness in test_typing.py.
üst
874dbe89
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
8 deletions
+27
-8
test_typing.py
Lib/test/test_typing.py
+14
-3
typing.py
Lib/typing.py
+10
-5
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/test_typing.py
Dosyayı görüntüle @
647bae6c
...
...
@@ -436,12 +436,14 @@ class CallableTests(TestCase):
c
()
def
test_callable_instance_works
(
self
):
f
=
lambda
:
None
def
f
():
pass
assert
isinstance
(
f
,
Callable
)
assert
not
isinstance
(
None
,
Callable
)
def
test_callable_instance_type_error
(
self
):
f
=
lambda
:
None
def
f
():
pass
with
self
.
assertRaises
(
TypeError
):
assert
isinstance
(
f
,
Callable
[[],
None
])
with
self
.
assertRaises
(
TypeError
):
...
...
@@ -674,7 +676,9 @@ class GenericTests(TestCase):
T
=
TypeVar
(
'T'
)
class
Node
(
Generic
[
T
]):
def
__init__
(
self
,
label
:
T
,
left
:
'Node[T]'
=
None
,
right
:
'Node[T]'
=
None
):
def
__init__
(
self
,
label
:
T
,
left
:
'Node[T]'
=
None
,
right
:
'Node[T]'
=
None
):
self
.
label
=
label
# type: T
self
.
left
=
left
# type: Optional[Node[T]]
self
.
right
=
right
# type: Optional[Node[T]]
...
...
@@ -933,9 +937,16 @@ class CollectionsAbcTests(TestCase):
assert
not
isinstance
([],
typing
.
Hashable
)
def
test_iterable
(
self
):
assert
isinstance
([],
typing
.
Iterable
)
# Due to ABC caching, the second time takes a separate code
# path and could fail. So call this a few times.
assert
isinstance
([],
typing
.
Iterable
)
assert
isinstance
([],
typing
.
Iterable
)
assert
isinstance
([],
typing
.
Iterable
[
int
])
assert
not
isinstance
(
42
,
typing
.
Iterable
)
# Just in case, also test issubclass() a few times.
assert
issubclass
(
list
,
typing
.
Iterable
)
assert
issubclass
(
list
,
typing
.
Iterable
)
def
test_iterator
(
self
):
it
=
iter
([])
...
...
Lib/typing.py
Dosyayı görüntüle @
647bae6c
# TODO:
# - Generic[T, T] is invalid
# - Look for TODO below
# TODO nits:
# Get rid of asserts that are the caller's fault.
# Docstrings (e.g. ABCs).
...
...
@@ -963,7 +959,8 @@ class GenericMeta(TypingMeta, abc.ABCMeta):
raise
TypeError
(
"Initial parameters must be "
"type variables; got
%
s"
%
p
)
if
len
(
set
(
params
))
!=
len
(
params
):
raise
TypeError
(
"All type variables in Generic[...] must be distinct."
)
raise
TypeError
(
"All type variables in Generic[...] must be distinct."
)
else
:
if
len
(
params
)
!=
len
(
self
.
__parameters__
):
raise
TypeError
(
"Cannot change parameter count from
%
d to
%
d"
%
...
...
@@ -987,6 +984,14 @@ class GenericMeta(TypingMeta, abc.ABCMeta):
origin
=
self
,
extra
=
self
.
__extra__
)
def
__instancecheck__
(
self
,
instance
):
# Since we extend ABC.__subclasscheck__ and
# ABC.__instancecheck__ inlines the cache checking done by the
# latter, we must extend __instancecheck__ too. For simplicity
# we just skip the cache check -- instance checks for generic
# classes are supposed to be rare anyways.
return
self
.
__subclasscheck__
(
instance
.
__class__
)
def
__subclasscheck__
(
self
,
cls
):
if
cls
is
Any
:
return
True
...
...
Misc/NEWS
Dosyayı görüntüle @
647bae6c
...
...
@@ -88,6 +88,9 @@ Core and Builtins
Library
-------
- Issue #24635: Fixed a bug in typing.py where isinstance([], typing.Iterable)
would return True once, then False on subsequent calls.
- Issue #24989: Fixed buffer overread in BytesIO.readline() if a position is
set beyond size. Based on patch by John Leitch.
...
...
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