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.
This commit is contained in:
Tim Peters 2001-09-04 05:14:19 +00:00
parent 1832de4bc0
commit 9fffa3eea3
5 changed files with 76 additions and 23 deletions

View file

@ -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;