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
4ad1d6f8
Kaydet (Commit)
4ad1d6f8
authored
May 17, 2009
tarafından
Robert Schuppenies
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 5964: Fixed WeakSet __eq__ comparison to handle non-WeakSet objects.
üst
441efa89
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
10 deletions
+15
-10
_weakrefset.py
Lib/_weakrefset.py
+2
-0
test_weakset.py
Lib/test/test_weakset.py
+13
-10
No files found.
Lib/_weakrefset.py
Dosyayı görüntüle @
4ad1d6f8
...
...
@@ -118,6 +118,8 @@ class WeakSet:
return
self
.
data
>=
set
(
ref
(
item
)
for
item
in
other
)
def
__eq__
(
self
,
other
):
if
not
isinstance
(
other
,
self
.
__class__
):
return
NotImplemented
return
self
.
data
==
set
(
ref
(
item
)
for
item
in
other
)
def
symmetric_difference
(
self
,
other
):
...
...
Lib/test/test_weakset.py
Dosyayı görüntüle @
4ad1d6f8
...
...
@@ -134,13 +134,11 @@ class TestWeakSet(unittest.TestCase):
def
test_gc
(
self
):
# Create a nest of cycles to exercise overall ref count check
class
A
:
pass
s
=
set
(
A
()
for
i
in
range
(
1000
))
s
=
WeakSet
(
Foo
()
for
i
in
range
(
1000
))
for
elem
in
s
:
elem
.
cycle
=
s
elem
.
sub
=
elem
elem
.
set
=
s
et
([
elem
])
elem
.
set
=
WeakS
et
([
elem
])
def
test_subclass_with_custom_hash
(
self
):
# Bug #1257731
...
...
@@ -169,17 +167,12 @@ class TestWeakSet(unittest.TestCase):
t
=
WeakSet
(
s
)
self
.
assertNotEqual
(
id
(
s
),
id
(
t
))
def
test_set_literal
(
self
):
s
=
set
([
1
,
2
,
3
])
t
=
{
1
,
2
,
3
}
self
.
assertEqual
(
s
,
t
)
def
test_hash
(
self
):
self
.
assertRaises
(
TypeError
,
hash
,
self
.
s
)
def
test_clear
(
self
):
self
.
s
.
clear
()
self
.
assertEqual
(
self
.
s
,
set
(
))
self
.
assertEqual
(
self
.
s
,
WeakSet
([]
))
self
.
assertEqual
(
len
(
self
.
s
),
0
)
def
test_copy
(
self
):
...
...
@@ -304,6 +297,16 @@ class TestWeakSet(unittest.TestCase):
t
^=
t
self
.
assertEqual
(
t
,
WeakSet
())
def
test_eq
(
self
):
# issue 5964
self
.
assertTrue
(
self
.
s
==
self
.
s
)
self
.
assertTrue
(
self
.
s
==
WeakSet
(
self
.
items
))
self
.
assertFalse
(
self
.
s
==
set
(
self
.
items
))
self
.
assertFalse
(
self
.
s
==
list
(
self
.
items
))
self
.
assertFalse
(
self
.
s
==
tuple
(
self
.
items
))
self
.
assertFalse
(
self
.
s
==
WeakSet
([
Foo
]))
self
.
assertFalse
(
self
.
s
==
1
)
def
test_main
(
verbose
=
None
):
support
.
run_unittest
(
TestWeakSet
)
...
...
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