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
15b1f146
Kaydet (Commit)
15b1f146
authored
Nis 18, 2006
tarafından
Michael W. Hudson
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
add a very old crasher from the 2.1 -> 2.2 round of dictionary fixes.
üst
952f196a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
nasty_eq_vs_dict.py
Lib/test/crashers/nasty_eq_vs_dict.py
+47
-0
No files found.
Lib/test/crashers/nasty_eq_vs_dict.py
0 → 100644
Dosyayı görüntüle @
15b1f146
# from http://mail.python.org/pipermail/python-dev/2001-June/015239.html
# if you keep changing a dictionary while looking up a key, you can
# provoke an infinite recursion in C
# At the time neither Tim nor Michael could be bothered to think of a
# way to fix it.
class
Yuck
:
def
__init__
(
self
):
self
.
i
=
0
def
make_dangerous
(
self
):
self
.
i
=
1
def
__hash__
(
self
):
# direct to slot 4 in table of size 8; slot 12 when size 16
return
4
+
8
def
__eq__
(
self
,
other
):
if
self
.
i
==
0
:
# leave dict alone
pass
elif
self
.
i
==
1
:
# fiddle to 16 slots
self
.
__fill_dict
(
6
)
self
.
i
=
2
else
:
# fiddle to 8 slots
self
.
__fill_dict
(
4
)
self
.
i
=
1
return
1
def
__fill_dict
(
self
,
n
):
self
.
i
=
0
dict
.
clear
()
for
i
in
range
(
n
):
dict
[
i
]
=
i
dict
[
self
]
=
"OK!"
y
=
Yuck
()
dict
=
{
y
:
"OK!"
}
z
=
Yuck
()
y
.
make_dangerous
()
print
dict
[
z
]
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