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
22999a69
Commit
22999a69
authored
Apr 25, 2009
by
Mark Dickinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #5829: complex('1e-500') shouldn't raise an exception.
Also fix some confusing indentation.
parent
de0d5e32
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
9 deletions
+14
-9
Lib/test/test_complex.py
Lib/test/test_complex.py
+3
-0
Misc/NEWS
Misc/NEWS
+2
-0
Objects/complexobject.c
Objects/complexobject.c
+9
-9
No files found.
Lib/test/test_complex.py
View file @
22999a69
...
...
@@ -220,6 +220,9 @@ class ComplexTest(unittest.TestCase):
self
.
assertAlmostEqual
(
complex
(
"+1"
),
+
1
)
self
.
assertAlmostEqual
(
complex
(
"(1+2j)"
),
1
+
2j
)
self
.
assertAlmostEqual
(
complex
(
"(1.3+2.2j)"
),
1.3
+
2.2j
)
self
.
assertAlmostEqual
(
complex
(
"1E-500"
),
1e-500
+
0j
)
self
.
assertAlmostEqual
(
complex
(
"1e-500J"
),
1e-500j
)
self
.
assertAlmostEqual
(
complex
(
"+1e-315-1e-400j"
),
1e-315
-
1e-400j
)
class
complex2
(
complex
):
pass
self
.
assertAlmostEqual
(
complex
(
complex2
(
1
+
1j
)),
1
+
1j
)
...
...
Misc/NEWS
View file @
22999a69
...
...
@@ -12,6 +12,8 @@ What's New in Python 2.6.3
Core and Builtins
-----------------
- Issue #5829: complex('1e-500') no longer raises an exception
- Issue #5787: object.__getattribute__(some_type, "__bases__") segfaulted on
some builtin types.
...
...
Objects/complexobject.c
View file @
22999a69
...
...
@@ -995,16 +995,16 @@ complex_subtype_from_string(PyTypeObject *type, PyObject *v)
}
errno
=
0
;
PyFPE_START_PROTECT
(
"strtod"
,
return
0
)
z
=
PyOS_ascii_strtod
(
s
,
&
end
)
;
z
=
PyOS_ascii_strtod
(
s
,
&
end
)
;
PyFPE_END_PROTECT
(
z
)
if
(
errno
!=
0
)
{
PyOS_snprintf
(
buffer
,
sizeof
(
buffer
),
"float() out of range: %.150s"
,
s
);
PyErr_SetString
(
PyExc_ValueError
,
buffer
);
return
NULL
;
}
if
(
errno
==
ERANGE
&&
fabs
(
z
)
>=
1
.
0
)
{
PyOS_snprintf
(
buffer
,
sizeof
(
buffer
),
"float() out of range: %.150s"
,
s
);
PyErr_SetString
(
PyExc_ValueError
,
buffer
);
return
NULL
;
}
s
=
end
;
if
(
*
s
==
'J'
||
*
s
==
'j'
)
{
...
...
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