From 71925a161831726d919c5301680263146d36e118 Mon Sep 17 00:00:00 2001
From: Robert Bradshaw <robertwb@math.washington.edu>
Date: Wed, 28 May 2008 00:18:34 -0700
Subject: [PATCH] Casting from C pointer to object does not incref

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 | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/Cython/Compiler/ExprNodes.py b/Cython/Compiler/ExprNodes.py
index 406da371d..57603692e 100644
--- a/Cython/Compiler/ExprNodes.py
+++ b/Cython/Compiler/ExprNodes.py
@@ -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
 
-- 
2.30.9