Temporary python object casts OK for numeric types.
authorRobert Bradshaw <robertwb@math.washington.edu>
Wed, 13 Feb 2008 03:05:47 +0000 (19:05 -0800)
committerRobert Bradshaw <robertwb@math.washington.edu>
Wed, 13 Feb 2008 03:05:47 +0000 (19:05 -0800)
Cython/Compiler/ExprNodes.py

index 824909b994983a31357655e1d5de80c60a547e0c..7892aed8d127f81aa8439ae298674185329a8c65 100644 (file)
@@ -2649,8 +2649,8 @@ class TypecastNode(ExprNode):
         self.operand.analyse_types(env)
         to_py = self.type.is_pyobject
         from_py = self.operand.type.is_pyobject
-        if from_py and not to_py and self.operand.is_ephemeral():
-            error(self.pos, "Casting temporary Python object to non-Python type")
+        if from_py and not to_py and self.operand.is_ephemeral() and not self.type.is_numeric:
+            error(self.pos, "Casting temporary Python object to non-numeric non-Python type")
         if to_py and not from_py:
             self.result_ctype = py_object_type
             self.is_temp = 1