mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-39871: Fix possible SystemError in atan2, copysign and remainder (GH-18806)
In math_2(), the first PyFloat_AsDouble() call should be checked for failure before the second call. Co-authored-by: Mark Dickinson <dickinsm@gmail.com>
This commit is contained in:
parent
3a8c56295d
commit
5208b4b379
3 changed files with 25 additions and 2 deletions
|
@ -1106,9 +1106,13 @@ math_2(PyObject *const *args, Py_ssize_t nargs,
|
|||
if (!_PyArg_CheckPositional(funcname, nargs, 2, 2))
|
||||
return NULL;
|
||||
x = PyFloat_AsDouble(args[0]);
|
||||
y = PyFloat_AsDouble(args[1]);
|
||||
if ((x == -1.0 || y == -1.0) && PyErr_Occurred())
|
||||
if (x == -1.0 && PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
y = PyFloat_AsDouble(args[1]);
|
||||
if (y == -1.0 && PyErr_Occurred()) {
|
||||
return NULL;
|
||||
}
|
||||
errno = 0;
|
||||
r = (*func)(x, y);
|
||||
if (Py_IS_NAN(r)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue