From: Stefan Behnel Date: Sat, 4 Dec 2010 06:49:57 +0000 (+0100) Subject: keep type information when coercing from C complex to Python complex X-Git-Tag: 0.14.alpha0~27 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=919ae40184e0398494b1e2986a737577292f5ede;p=cython.git keep type information when coercing from C complex to Python complex --- 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"