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
b904e425
Kaydet (Commit)
b904e425
authored
Kas 01, 2012
tarafından
Andrew Svetlov
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge issue #16373: Prevent infinite recursion for ABC Set class operations.
Patch by Serhiy Storchaka.
üst
5e5bbfb6
bcac6ad1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
2 deletions
+35
-2
abc.py
Lib/collections/abc.py
+2
-2
test_collections.py
Lib/test/test_collections.py
+33
-0
No files found.
Lib/collections/abc.py
Dosyayı görüntüle @
b904e425
...
...
@@ -200,12 +200,12 @@ class Set(Sized, Iterable, Container):
def
__gt__
(
self
,
other
):
if
not
isinstance
(
other
,
Set
):
return
NotImplemented
return
other
<
self
return
other
.
__lt__
(
self
)
def
__ge__
(
self
,
other
):
if
not
isinstance
(
other
,
Set
):
return
NotImplemented
return
other
<=
self
return
other
.
__le__
(
self
)
def
__eq__
(
self
,
other
):
if
not
isinstance
(
other
,
Set
):
...
...
Lib/test/test_collections.py
Dosyayı görüntüle @
b904e425
...
...
@@ -663,6 +663,39 @@ class TestCollectionABCs(ABCTestCase):
s
|=
s
self
.
assertEqual
(
s
,
full
)
def
test_issue16373
(
self
):
# Recursion error comparing comparable and noncomparable
# Set instances
class
MyComparableSet
(
Set
):
def
__contains__
(
self
,
x
):
return
False
def
__len__
(
self
):
return
0
def
__iter__
(
self
):
return
iter
([])
class
MyNonComparableSet
(
Set
):
def
__contains__
(
self
,
x
):
return
False
def
__len__
(
self
):
return
0
def
__iter__
(
self
):
return
iter
([])
def
__le__
(
self
,
x
):
return
NotImplemented
def
__lt__
(
self
,
x
):
return
NotImplemented
cs
=
MyComparableSet
()
ncs
=
MyNonComparableSet
()
with
self
.
assertRaises
(
TypeError
):
ncs
<
cs
with
self
.
assertRaises
(
TypeError
):
ncs
<=
cs
with
self
.
assertRaises
(
TypeError
):
cs
>
ncs
with
self
.
assertRaises
(
TypeError
):
cs
>=
ncs
def
test_Mapping
(
self
):
for
sample
in
[
dict
]:
self
.
assertIsInstance
(
sample
(),
Mapping
)
...
...
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