From: Guido van Rossum Date: Wed, 19 Sep 2001 01:13:10 +0000 (+0000) Subject: complex_coerce(): add explicit PyComplex_Check() test. Previously, X-Git-Tag: v2.2.1c1~1740 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=638059603ca96a1e9b6d05f4d5c51a06a17b63ec;p=thirdparty%2FPython%2Fcpython.git complex_coerce(): add explicit PyComplex_Check() test. Previously, complex_coerce() would never be called with a complex argument, because PyNumber_Coerce[Ex] doesn't bother calling the type's coercion method if the values already have the same type. But now, of course, it's possible to pass an instance of a complex *subtype*, and those must be accepted. --- diff --git a/Objects/complexobject.c b/Objects/complexobject.c index a8419e31ae5f..a2ccadb78ad6 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -538,6 +538,11 @@ complex_coerce(PyObject **pv, PyObject **pw) Py_INCREF(*pv); return 0; } + else if (PyComplex_Check(*pw)) { + Py_INCREF(*pv); + Py_INCREF(*pw); + return 0; + } return 1; /* Can't do it */ }