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
bea3f6f5
Kaydet (Commit)
bea3f6f5
authored
Mar 15, 2005
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Bug #1163325: "special" decimals aren't hashable
üst
141f41ae
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
0 deletions
+10
-0
decimal.py
Lib/decimal.py
+4
-0
test_decimal.py
Lib/test/test_decimal.py
+3
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/decimal.py
Dosyayı görüntüle @
bea3f6f5
...
@@ -728,6 +728,10 @@ class Decimal(object):
...
@@ -728,6 +728,10 @@ class Decimal(object):
# Decimal integers must hash the same as the ints
# Decimal integers must hash the same as the ints
# Non-integer decimals are normalized and hashed as strings
# Non-integer decimals are normalized and hashed as strings
# Normalization assures that hast(100E-1) == hash(10)
# Normalization assures that hast(100E-1) == hash(10)
if
self
.
_is_special
:
if
self
.
_isnan
():
raise
TypeError
(
'Cannot hash a NaN value.'
)
return
hash
(
str
(
self
))
i
=
int
(
self
)
i
=
int
(
self
)
if
self
==
Decimal
(
i
):
if
self
==
Decimal
(
i
):
return
hash
(
i
)
return
hash
(
i
)
...
...
Lib/test/test_decimal.py
Dosyayı görüntüle @
bea3f6f5
...
@@ -811,6 +811,9 @@ class DecimalUsabilityTest(unittest.TestCase):
...
@@ -811,6 +811,9 @@ class DecimalUsabilityTest(unittest.TestCase):
hash
(
Decimal
(
23
))
hash
(
Decimal
(
23
))
#the same hash that to an int
#the same hash that to an int
self
.
assertEqual
(
hash
(
Decimal
(
23
)),
hash
(
23
))
self
.
assertEqual
(
hash
(
Decimal
(
23
)),
hash
(
23
))
self
.
assertRaises
(
TypeError
,
hash
,
Decimal
(
'NaN'
))
self
.
assert_
(
hash
(
Decimal
(
'Inf'
)))
self
.
assert_
(
hash
(
Decimal
(
'-Inf'
)))
def
test_min_and_max_methods
(
self
):
def
test_min_and_max_methods
(
self
):
...
...
Misc/NEWS
Dosyayı görüntüle @
bea3f6f5
...
@@ -86,6 +86,9 @@ Extension Modules
...
@@ -86,6 +86,9 @@ Extension Modules
Library
Library
-------
-------
- Bug #1163325: Decimal infinities failed to hash. Attempting to
hash a NaN raised an InvalidOperation instead of a TypeError.
- Patch #918101: Add tarfile open mode r|* for auto-detection of the
- Patch #918101: Add tarfile open mode r|* for auto-detection of the
stream compression; add, for symmetry reasons, r:* as a synonym of r.
stream compression; add, for symmetry reasons, r:* as a synonym of r.
...
...
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