let char*->bytes conversion know that it returns bytes
authorStefan Behnel <scoder@users.berlios.de>
Sat, 28 Nov 2009 08:10:25 +0000 (09:10 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Sat, 28 Nov 2009 08:10:25 +0000 (09:10 +0100)
Cython/Compiler/ExprNodes.py

index 709d5a027fd8f8ff9bc3b9fe46871a85fe597e79..21b3bf1cf8b3a3d4983e6342726e4ee3dd2807fe 100644 (file)
@@ -5690,11 +5690,15 @@ class CoerceToPyTypeNode(CoercionNode):
     type = py_object_type
     is_temp = 1
 
-    def __init__(self, arg, env):
+    def __init__(self, arg, env, type=py_object_type):
         CoercionNode.__init__(self, arg)
         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 = Builtin.bytes_type
 
     gil_message = "Converting to Python object"