diff options
author | Tim Peters <tim.peters@gmail.com> | 2001-09-04 05:14:19 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2001-09-04 05:14:19 (GMT) |
commit | 9fffa3eea3a7e99b0179988e7a016a45bf63ab96 (patch) | |
tree | 1b891e323dff2790bcd2b74ad4071cb0d380803d /Objects/complexobject.c | |
parent | 1832de4bc07e7ffd5938b41e8d7d8fcf8b5e12e2 (diff) | |
download | cpython-9fffa3eea3a7e99b0179988e7a016a45bf63ab96.zip cpython-9fffa3eea3a7e99b0179988e7a016a45bf63ab96.tar.gz cpython-9fffa3eea3a7e99b0179988e7a016a45bf63ab96.tar.bz2 |
Raise OverflowError when appropriate on long->float conversion. Most of
the fiddling is simply due to that no caller of PyLong_AsDouble ever
checked for failure (so that's fixing old bugs). PyLong_AsDouble is much
faster for big inputs now too, but that's more of a happy consequence
than a design goal.
Diffstat (limited to 'Objects/complexobject.c')
-rw-r--r-- | Objects/complexobject.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/Objects/complexobject.c b/Objects/complexobject.c index 236f4d5..7404993 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -522,6 +522,8 @@ complex_coerce(PyObject **pv, PyObject **pw) } else if (PyLong_Check(*pw)) { cval.real = PyLong_AsDouble(*pw); + if (cval.real == -1.0 && PyErr_Occurred()) + return -1; *pw = PyComplex_FromCComplex(cval); Py_INCREF(*pv); return 0; |