From: Guido van Rossum Date: Fri, 12 Jan 1996 01:21:14 +0000 (+0000) Subject: Added PyComplex_AsCComplex X-Git-Tag: v1.4b1~414 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cf3d1087d1285be03a1e450a39130aea74890c67;p=python Added PyComplex_AsCComplex --- diff --git a/Objects/complexobject.c b/Objects/complexobject.c index 8299b0b733..20eab1e1f6 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -208,6 +208,18 @@ PyComplex_ImagAsDouble(PyObject *op) { } } +complex +PyComplex_AsCComplex(PyObject *op) { + complex cv; + if (PyComplex_Check(op)) { + return ((PyComplexObject *)op)->cval; + } else { + cv.real = PyFloat_AsDouble(op); + cv.imag = 0.; + return cv; + } +} + static void complex_dealloc(op) object *op;