Casting from C pointer to object does not incref
authorRobert Bradshaw <robertwb@math.washington.edu>
Wed, 28 May 2008 07:18:34 +0000 (00:18 -0700)
committerRobert Bradshaw <robertwb@math.washington.edu>
Wed, 28 May 2008 07:18:34 +0000 (00:18 -0700)
Casting a non-Python pointer type to a Python type no longer
generates an incref, unless one is required for other reasons.
    [Arc Riley]

Cython/Compiler/ExprNodes.py

index 406da371d1756c6dd43a1ca6d638a8b09abdfda7..57603692e49f3bdb1184dc7e522d87a824530d8d 100644 (file)
@@ -2737,9 +2737,8 @@ class TypecastNode(ExprNode):
         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
             if self.operand.type.to_py_function:
+                self.result_ctype = py_object_type
                 self.operand = self.operand.coerce_to_pyobject(env)
             else:
                 warning(self.pos, "No conversion from %s to %s, python object pointer used." % (self.operand.type, self.type))
@@ -3850,9 +3849,6 @@ class CloneNode(CoercionNode):
         if hasattr(self.arg, 'entry'):
             self.entry = self.arg.entry
     
-    #def result_as_extension_type(self):
-    #  return self.arg.result_as_extension_type()
-    
     def generate_evaluation_code(self, code):
         pass