diff options
| author | Ezio Melotti <ezio.melotti@gmail.com> | 2012-11-18 14:06:54 +0200 |
|---|---|---|
| committer | Ezio Melotti <ezio.melotti@gmail.com> | 2012-11-18 14:06:54 +0200 |
| commit | 23e41c9686435a8a01da7fead079c783087ee5c5 (patch) | |
| tree | 0593cf00b74bcabb8cb52c2108750c2f80fa2c81 /Objects/complexobject.c | |
| parent | 68a2b84e68c3fe3abaa1bae589e17bfbb13461c2 (diff) | |
| parent | e93555d91c4608e06e3058a42af0f2450c9dfd19 (diff) | |
| download | cpython-23e41c9686435a8a01da7fead079c783087ee5c5.tar.gz | |
#16306: merge with 3.3.
Diffstat (limited to 'Objects/complexobject.c')
| -rw-r--r-- | Objects/complexobject.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Objects/complexobject.c b/Objects/complexobject.c index 403c60c917..355b063f28 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -271,6 +271,12 @@ try_complex_special_method(PyObject *op) { if (f) { PyObject *res = PyObject_CallFunctionObjArgs(f, NULL); Py_DECREF(f); + if (res != NULL && !PyComplex_Check(res)) { + PyErr_SetString(PyExc_TypeError, + "__complex__ should return a complex object"); + Py_DECREF(res); + return NULL; + } return res; } return NULL; @@ -296,12 +302,6 @@ PyComplex_AsCComplex(PyObject *op) newop = try_complex_special_method(op); if (newop) { - if (!PyComplex_Check(newop)) { - PyErr_SetString(PyExc_TypeError, - "__complex__ should return a complex object"); - Py_DECREF(newop); - return cv; - } cv = ((PyComplexObject *)newop)->cval; Py_DECREF(newop); return cv; |
