self.assertEquals(atan2(z1.imag, -1.), atan2(0., -1.))
self.assertEquals(atan2(z2.imag, -1.), atan2(-0., -1.))
+ @unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
+ "test requires IEEE 754 doubles")
+ def test_overflow(self):
+ self.assertEqual(complex("1e500"), complex(INF, 0.0))
+ self.assertEqual(complex("-1e500j"), complex(0.0, -INF))
+ self.assertEqual(complex("-1e500+1.8e308j"), complex(-INF, INF))
+
@unittest.skipUnless(float.__getformat__("double").startswith("IEEE"),
"test requires IEEE 754 doubles")
def test_repr_roundtrip(self):
Core and Builtins
-----------------
+- Issue #5829: complex("1e500") no longer raises OverflowError. This
+ makes it consistent with float("1e500") and interpretation of real
+ and imaginary literals.
+
- Issue #3527: Removed Py_WIN_WIDE_FILENAMES which is not used any more.
- Issue #5994: the marshal module now has docstrings.
*/
/* first look for forms starting with <float> */
- z = PyOS_string_to_double(s, &end, PyExc_OverflowError);
+ z = PyOS_string_to_double(s, &end, NULL);
if (z == -1.0 && PyErr_Occurred()) {
if (PyErr_ExceptionMatches(PyExc_ValueError))
PyErr_Clear();
if (*s == '+' || *s == '-') {
/* <float><signed-float>j | <float><sign>j */
x = z;
- y = PyOS_string_to_double(s, &end, PyExc_OverflowError);
+ y = PyOS_string_to_double(s, &end, NULL);
if (y == -1.0 && PyErr_Occurred()) {
if (PyErr_ExceptionMatches(PyExc_ValueError))
PyErr_Clear();