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
f0f1c239
Kaydet (Commit)
f0f1c239
authored
8 years ago
tarafından
Raymond Hettinger
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue 27936: Fix inconsistent round() behavior between float and int
üst
22c108f0
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
2 deletions
+17
-2
test_builtin.py
Lib/test/test_builtin.py
+11
-0
test_long.py
Lib/test/test_long.py
+1
-1
NEWS
Misc/NEWS
+4
-0
bltinmodule.c
Python/bltinmodule.c
+1
-1
No files found.
Lib/test/test_builtin.py
Dosyayı görüntüle @
f0f1c239
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
import
ast
import
ast
import
builtins
import
builtins
import
collections
import
collections
import
decimal
import
fractions
import
io
import
io
import
locale
import
locale
import
os
import
os
...
@@ -1244,6 +1246,15 @@ class BuiltinTest(unittest.TestCase):
...
@@ -1244,6 +1246,15 @@ class BuiltinTest(unittest.TestCase):
self
.
assertEqual
(
round
(
5e15
+
2
),
5e15
+
2
)
self
.
assertEqual
(
round
(
5e15
+
2
),
5e15
+
2
)
self
.
assertEqual
(
round
(
5e15
+
3
),
5e15
+
3
)
self
.
assertEqual
(
round
(
5e15
+
3
),
5e15
+
3
)
def
test_bug_27936
(
self
):
# Verify that ndigits=None means the same as passing in no argument
for
x
in
[
1234
,
1234.56
,
decimal
.
Decimal
(
'1234.56'
),
fractions
.
Fraction
(
123456
,
100
)]:
self
.
assertEqual
(
round
(
x
,
None
),
round
(
x
))
self
.
assertEqual
(
type
(
round
(
x
,
None
)),
type
(
round
(
x
)))
def
test_setattr
(
self
):
def
test_setattr
(
self
):
setattr
(
sys
,
'spam'
,
1
)
setattr
(
sys
,
'spam'
,
1
)
self
.
assertEqual
(
sys
.
spam
,
1
)
self
.
assertEqual
(
sys
.
spam
,
1
)
...
...
This diff is collapsed.
Click to expand it.
Lib/test/test_long.py
Dosyayı görüntüle @
f0f1c239
...
@@ -967,7 +967,7 @@ class LongTest(unittest.TestCase):
...
@@ -967,7 +967,7 @@ class LongTest(unittest.TestCase):
self
.
assertIs
(
type
(
got
),
int
)
self
.
assertIs
(
type
(
got
),
int
)
# bad second argument
# bad second argument
bad_exponents
=
(
'brian'
,
2.0
,
0
j
,
None
)
bad_exponents
=
(
'brian'
,
2.0
,
0
j
)
for
e
in
bad_exponents
:
for
e
in
bad_exponents
:
self
.
assertRaises
(
TypeError
,
round
,
3
,
e
)
self
.
assertRaises
(
TypeError
,
round
,
3
,
e
)
...
...
This diff is collapsed.
Click to expand it.
Misc/NEWS
Dosyayı görüntüle @
f0f1c239
...
@@ -18,6 +18,10 @@ Core and Builtins
...
@@ -18,6 +18,10 @@ Core and Builtins
``m_methods`` field to be used to add module level functions to instances
``m_methods`` field to be used to add module level functions to instances
of non-module types returned from ``Py_create_mod``. Patch by Xiang Zhang.
of non-module types returned from ``Py_create_mod``. Patch by Xiang Zhang.
- Issue #27936: The round() function accepted a second None argument
for some types but not for others. Fixed the inconsistency by
accepting None for all numeric types.
- Issue #27487: Warn if a submodule argument to "python -m" or
- Issue #27487: Warn if a submodule argument to "python -m" or
runpy.run_module() is found in sys.modules after parent packages are
runpy.run_module() is found in sys.modules after parent packages are
imported, but before the submodule is executed.
imported, but before the submodule is executed.
...
...
This diff is collapsed.
Click to expand it.
Python/bltinmodule.c
Dosyayı görüntüle @
f0f1c239
...
@@ -2039,7 +2039,7 @@ builtin_round(PyObject *self, PyObject *args, PyObject *kwds)
...
@@ -2039,7 +2039,7 @@ builtin_round(PyObject *self, PyObject *args, PyObject *kwds)
return
NULL
;
return
NULL
;
}
}
if
(
ndigits
==
NULL
)
if
(
ndigits
==
NULL
||
ndigits
==
Py_None
)
result
=
PyObject_CallFunctionObjArgs
(
round
,
NULL
);
result
=
PyObject_CallFunctionObjArgs
(
round
,
NULL
);
else
else
result
=
PyObject_CallFunctionObjArgs
(
round
,
ndigits
,
NULL
);
result
=
PyObject_CallFunctionObjArgs
(
round
,
ndigits
,
NULL
);
...
...
This diff is collapsed.
Click to expand it.
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