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
6d1dece0
Kaydet (Commit)
6d1dece0
authored
Şub 14, 2017
tarafından
Andrew Nester
Kaydeden (comit)
Mark Dickinson
Şub 14, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #29534 - _decimal difference with _pydecimal (#65)
üst
c33ee85b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
11 deletions
+28
-11
_pydecimal.py
Lib/_pydecimal.py
+16
-11
test_decimal.py
Lib/test/test_decimal.py
+10
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/_pydecimal.py
Dosyayı görüntüle @
6d1dece0
...
@@ -734,18 +734,23 @@ class Decimal(object):
...
@@ -734,18 +734,23 @@ class Decimal(object):
"""
"""
if
isinstance
(
f
,
int
):
# handle integer inputs
if
isinstance
(
f
,
int
):
# handle integer inputs
return
cls
(
f
)
sign
=
0
if
f
>=
0
else
1
if
not
isinstance
(
f
,
float
):
k
=
0
raise
TypeError
(
"argument must be int or float."
)
coeff
=
str
(
abs
(
f
))
if
_math
.
isinf
(
f
)
or
_math
.
isnan
(
f
):
elif
isinstance
(
f
,
float
):
return
cls
(
repr
(
f
))
if
_math
.
isinf
(
f
)
or
_math
.
isnan
(
f
):
if
_math
.
copysign
(
1.0
,
f
)
==
1.0
:
return
cls
(
repr
(
f
))
sign
=
0
if
_math
.
copysign
(
1.0
,
f
)
==
1.0
:
sign
=
0
else
:
sign
=
1
n
,
d
=
abs
(
f
)
.
as_integer_ratio
()
k
=
d
.
bit_length
()
-
1
coeff
=
str
(
n
*
5
**
k
)
else
:
else
:
sign
=
1
raise
TypeError
(
"argument must be int or float."
)
n
,
d
=
abs
(
f
)
.
as_integer_ratio
()
k
=
d
.
bit_length
()
-
1
result
=
_dec_from_triple
(
sign
,
coeff
,
-
k
)
result
=
_dec_from_triple
(
sign
,
str
(
n
*
5
**
k
),
-
k
)
if
cls
is
Decimal
:
if
cls
is
Decimal
:
return
result
return
result
else
:
else
:
...
...
Lib/test/test_decimal.py
Dosyayı görüntüle @
6d1dece0
...
@@ -1185,6 +1185,16 @@ class FormatTest(unittest.TestCase):
...
@@ -1185,6 +1185,16 @@ class FormatTest(unittest.TestCase):
self
.
assertEqual
(
format
(
Decimal
(
'100000000.123'
),
'n'
),
self
.
assertEqual
(
format
(
Decimal
(
'100000000.123'
),
'n'
),
'100
\u066c
000
\u066c
000
\u066b
123'
)
'100
\u066c
000
\u066c
000
\u066b
123'
)
def
test_decimal_from_float_argument_type
(
self
):
class
A
(
self
.
decimal
.
Decimal
):
def
__init__
(
self
,
a
):
self
.
a_type
=
type
(
a
)
a
=
A
.
from_float
(
42.5
)
self
.
assertEqual
(
self
.
decimal
.
Decimal
,
a
.
a_type
)
a
=
A
.
from_float
(
42
)
self
.
assertEqual
(
self
.
decimal
.
Decimal
,
a
.
a_type
)
class
CFormatTest
(
FormatTest
):
class
CFormatTest
(
FormatTest
):
decimal
=
C
decimal
=
C
class
PyFormatTest
(
FormatTest
):
class
PyFormatTest
(
FormatTest
):
...
...
Misc/NEWS
Dosyayı görüntüle @
6d1dece0
...
@@ -10,6 +10,8 @@ What's New in Python 3.7.0 alpha 1?
...
@@ -10,6 +10,8 @@ What's New in Python 3.7.0 alpha 1?
Core and Builtins
Core and Builtins
-----------------
-----------------
- bpo-29534: Fixed different behaviour of Decimal.from_float() for _decimal and _pydecimal.
- bpo-29438: Fixed use-after-free problem in key sharing dict.
- bpo-29438: Fixed use-after-free problem in key sharing dict.
- Issue #29319: Prevent RunMainFromImporter overwriting sys.path[0].
- Issue #29319: Prevent RunMainFromImporter overwriting sys.path[0].
...
...
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