avoid recursive coercion in CoerceToPyTypeNode
authorStefan Behnel <scoder@users.berlios.de>
Thu, 18 Dec 2008 17:04:44 +0000 (18:04 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Thu, 18 Dec 2008 17:04:44 +0000 (18:04 +0100)
Cython/Compiler/ExprNodes.py

index 8e14914d95167a49f473aa29d2f4bbddb8388f57..c4bcd674185ded0ffb5591e09a4c30033aea79c7 100644 (file)
@@ -4932,6 +4932,13 @@ class CoerceToPyTypeNode(CoercionNode):
     
     def coerce_to_boolean(self, env):
         return self.arg.coerce_to_boolean(env).coerce_to_temp(env)
+    
+    def coerce_to_integer(self, env):
+        # If not already some C integer type, coerce to longint.
+        if self.arg.type.is_int:
+            return self.arg
+        else:
+            return self.arg.coerce_to(PyrexTypes.c_long_type, env)
 
     def analyse_types(self, env):
         # The arg is always already analysed