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
0e701695
Commit
0e701695
authored
Jan 15, 2008
by
Christian Heimes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
long(float('nan')) raises an OverflowError as discussed on the mailing list a week ago
parent
02c10eb1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
2 deletions
+7
-2
Lib/test/test_long.py
Lib/test/test_long.py
+1
-1
Misc/NEWS
Misc/NEWS
+3
-0
Objects/longobject.c
Objects/longobject.c
+3
-1
No files found.
Lib/test/test_long.py
View file @
0e701695
...
...
@@ -539,7 +539,7 @@ class LongTest(unittest.TestCase):
def
test_nan_inf
(
self
):
self
.
assertRaises
(
OverflowError
,
int
,
float
(
'inf'
))
self
.
assert
Equal
(
int
(
float
(
'nan'
)),
0
)
self
.
assert
Raises
(
OverflowError
,
int
,
float
(
'nan'
)
)
def
test_main
():
test_support
.
run_unittest
(
LongTest
)
...
...
Misc/NEWS
View file @
0e701695
...
...
@@ -12,6 +12,9 @@ What's New in Python 3.0a3?
Core and Builtins
-----------------
- Object/longobject.c: long(float('nan')) raises an OverflowError instead
of returning 0.
- Issue #1762972: __file__ points to the source file instead of the pyc/pyo
file if the py file exists.
...
...
Objects/longobject.c
View file @
0e701695
...
...
@@ -255,7 +255,9 @@ PyLong_FromDouble(double dval)
return
NULL
;
}
if
(
Py_IS_NAN
(
dval
))
{
return
PyLong_FromLong
(
0L
);
PyErr_SetString
(
PyExc_OverflowError
,
"cannot convert float NaN to int"
);
return
NULL
;
}
if
(
dval
<
0
.
0
)
{
neg
=
1
;
...
...
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