From 919ae40184e0398494b1e2986a737577292f5ede Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Sat, 4 Dec 2010 07:49:57 +0100 Subject: [PATCH] keep type information when coercing from C complex to Python complex --- Cython/Compiler/ExprNodes.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py index d721a69e..d58e9823 100755 --- a/Cython/Compiler/ExprNodes.py +++ b/Cython/Compiler/ExprNodes.py @@ -7074,12 +7074,17 @@ class CoerceToPyTypeNode(CoercionNode): if not arg.type.create_to_py_utility_code(env): error(arg.pos, "Cannot convert '%s' to Python object" % arg.type) - if type is not py_object_type: - self.type = py_object_type - elif arg.type.is_string: - self.type = bytes_type - elif arg.type is PyrexTypes.c_py_unicode_type: - self.type = unicode_type + if type is py_object_type: + # be specific about some known types + if arg.type.is_string: + self.type = bytes_type + elif arg.type is PyrexTypes.c_py_unicode_type: + self.type = unicode_type + elif arg.type.is_complex: + self.type = Builtin.complex_type + else: + # FIXME: check that the target type and the resulting type are compatible + pass gil_message = "Converting to Python object" -- 2.26.2