summaryrefslogtreecommitdiffstats
path: root/Objects/complexobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/complexobject.c')
-rw-r--r--Objects/complexobject.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/Objects/complexobject.c b/Objects/complexobject.c
index 8299b0b..20eab1e 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;