mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
1832de4bc0
commit
9fffa3eea3
5 changed files with 76 additions and 23 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue