Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
abcb0c03
Commit
abcb0c03
authored
Jan 28, 2003
by
Neal Norwitz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix SF bug# 676155, RuntimeWarning with tp_compare
Check return value of PyLong_AsDouble(), it can return an error.
parent
54fb1925
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
3 deletions
+13
-3
Lib/test/test_builtin.py
Lib/test/test_builtin.py
+1
-0
Lib/test/test_long.py
Lib/test/test_long.py
+4
-2
Misc/NEWS
Misc/NEWS
+4
-0
Objects/floatobject.c
Objects/floatobject.c
+4
-1
No files found.
Lib/test/test_builtin.py
View file @
abcb0c03
...
...
@@ -186,6 +186,7 @@ class BuiltinTest(unittest.TestCase):
def
__coerce__
(
self
,
other
):
raise
ValueError
self
.
assertRaises
(
ValueError
,
coerce
,
42
,
BadNumber
())
self
.
assertRaises
(
OverflowError
,
coerce
,
0.5
,
int
(
"12345"
*
1000
))
def
test_compile
(
self
):
compile
(
'print 1
\
n
'
,
''
,
'exec'
)
...
...
Lib/test/test_long.py
View file @
abcb0c03
...
...
@@ -371,9 +371,10 @@ def test_float_overflow():
for
x
in
-
2.0
,
-
1.0
,
0.0
,
1.0
,
2.0
:
verify
(
float
(
long
(
x
))
==
x
)
shuge
=
'12345'
*
1000
huge
=
1L
<<
30000
mhuge
=
-
huge
namespace
=
{
'huge'
:
huge
,
'mhuge'
:
mhuge
,
'math'
:
math
}
namespace
=
{
'huge'
:
huge
,
'mhuge'
:
mhuge
,
'
shuge'
:
shuge
,
'
math'
:
math
}
for
test
in
[
"float(huge)"
,
"float(mhuge)"
,
"complex(huge)"
,
"complex(mhuge)"
,
"complex(huge, 1)"
,
"complex(mhuge, 1)"
,
...
...
@@ -386,7 +387,8 @@ def test_float_overflow():
"1. ** huge"
,
"huge ** 1."
,
"1. ** mhuge"
,
"mhuge ** 1."
,
"math.sin(huge)"
,
"math.sin(mhuge)"
,
"math.sqrt(huge)"
,
"math.sqrt(mhuge)"
,
# should do better
"math.floor(huge)"
,
"math.floor(mhuge)"
]:
"math.floor(huge)"
,
"math.floor(mhuge)"
,
"float(shuge) == int(shuge)"
]:
try
:
eval
(
test
,
namespace
)
...
...
Misc/NEWS
View file @
abcb0c03
...
...
@@ -23,6 +23,10 @@ Core and builtins
-
Fixed
crash
when
printing
a
subclass
of
str
and
__str__
returned
self
.
See
SF
bug
#
667147.
-
Fixed
an
invalid
RuntimeWarning
and
an
undetected
error
when
trying
to
convert
a
long
integer
into
a
float
which
couldn
't fit.
See SF bug #676155.
Extension modules
-----------------
...
...
Objects/floatobject.c
View file @
abcb0c03
...
...
@@ -629,7 +629,10 @@ float_coerce(PyObject **pv, PyObject **pw)
return
0
;
}
else
if
(
PyLong_Check
(
*
pw
))
{
*
pw
=
PyFloat_FromDouble
(
PyLong_AsDouble
(
*
pw
));
double
x
=
PyLong_AsDouble
(
*
pw
);
if
(
x
==
-
1
.
0
&&
PyErr_Occurred
())
return
-
1
;
*
pw
=
PyFloat_FromDouble
(
x
);
Py_INCREF
(
*
pv
);
return
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