mirror of
https://github.com/python/cpython.git
synced 2025-10-16 19:57:59 +00:00
Fix for the bug in complex() just reported by Ping.
This commit is contained in:
parent
90cb9067b8
commit
8dabbf149e
1 changed files with 7 additions and 1 deletions
|
@ -591,12 +591,18 @@ builtin_complex(PyObject *self, PyObject *args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tmp = (*nbr->nb_float)(r);
|
tmp = PyNumber_Float(r);
|
||||||
if (own_r) {
|
if (own_r) {
|
||||||
Py_DECREF(r);
|
Py_DECREF(r);
|
||||||
}
|
}
|
||||||
if (tmp == NULL)
|
if (tmp == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
if (!PyFloat_Check(tmp)) {
|
||||||
|
PyErr_SetString(PyExc_TypeError,
|
||||||
|
"float(r) didn't return a float");
|
||||||
|
Py_DECREF(tmp);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
cr.real = PyFloat_AsDouble(tmp);
|
cr.real = PyFloat_AsDouble(tmp);
|
||||||
Py_DECREF(tmp);
|
Py_DECREF(tmp);
|
||||||
cr.imag = 0.0;
|
cr.imag = 0.0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue