summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-01-19 02:11:59 (GMT)
committerGuido van Rossum <guido@python.org>2001-01-19 02:11:59 (GMT)
commit8dabbf149e351c801a7d3b65891c49949be8251c (patch)
tree57d17acb46f51a0958a20f62e10b0d25cc9e087e /Python
parent90cb9067b82509ed4917084ffa85abc150509ff5 (diff)
downloadcpython-8dabbf149e351c801a7d3b65891c49949be8251c.zip
cpython-8dabbf149e351c801a7d3b65891c49949be8251c.tar.gz
cpython-8dabbf149e351c801a7d3b65891c49949be8251c.tar.bz2
Fix for the bug in complex() just reported by Ping.
Diffstat (limited to 'Python')
-rw-r--r--Python/bltinmodule.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 3acd0e2..ca9f312 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -591,12 +591,18 @@ builtin_complex(PyObject *self, PyObject *args)
}
}
else {
- tmp = (*nbr->nb_float)(r);
+ tmp = PyNumber_Float(r);
if (own_r) {
Py_DECREF(r);
}
if (tmp == 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);
Py_DECREF(tmp);
cr.imag = 0.0;