Fix #200 (together with Lisandro Dalcin)
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Fri, 20 Feb 2009 00:50:40 +0000 (01:50 +0100)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Fri, 20 Feb 2009 00:50:40 +0000 (01:50 +0100)
Cython/Compiler/Nodes.py

index 310bdb49a24ad8166a3070ac2f4baa4ec27f37c5..4391328437d1d89dfe234cb548d895859959cf7b 100644 (file)
@@ -1054,6 +1054,8 @@ class FuncDefNode(StatNode, BlockNode):
         code.put_var_declarations(lenv.var_entries)
         init = ""
         if not self.return_type.is_void:
+            if self.return_type.is_pyobject:
+                init = " = NULL"
             code.putln(
                 "%s%s;" % 
                     (self.return_type.declaration_code(
@@ -3370,6 +3372,9 @@ class ReturnStatNode(StatNode):
         if not self.return_type:
             # error reported earlier
             return
+        if self.return_type.is_pyobject:
+            code.put_xdecref(Naming.retval_cname,
+                             self.return_type)
         if self.value:
             self.value.generate_evaluation_code(code)
             self.value.make_owned_reference(code)