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
3a3f9cc9
Kaydet (Commit)
3a3f9cc9
authored
Mar 15, 2005
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Decimal special values did not hash properly.
üst
3b0dad06
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 @
3a3f9cc9
...
@@ -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 @
3a3f9cc9
...
@@ -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 @
3a3f9cc9
...
@@ -12,6 +12,9 @@ What's New in Python 2.4.1c2?
...
@@ -12,6 +12,9 @@ What's New in Python 2.4.1c2?
Library
Library
-------
-------
- Bug #1163325: Decimal infinities failed to hash. Attempting to
hash a NaN raised an InvalidOperation instead of a TypeError.
- Bug #1160802: can'
t
build
Zope
on
Windows
with
2.4.1
c1
.
The
- Bug #1160802: can'
t
build
Zope
on
Windows
with
2.4.1
c1
.
The
``
MSVCCompiler
``
class
in
distutils
forgot
to
record
that
it
was
``
MSVCCompiler
``
class
in
distutils
forgot
to
record
that
it
was
initialized
,
and
continued
adding
redundant
entries
to
the
system
initialized
,
and
continued
adding
redundant
entries
to
the
system
...
...
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