C code simplification
authorStefan Behnel <scoder@users.berlios.de>
Tue, 14 Dec 2010 05:49:49 +0000 (06:49 +0100)
committerStefan Behnel <scoder@users.berlios.de>
Tue, 14 Dec 2010 05:49:49 +0000 (06:49 +0100)
Cython/Compiler/Code.py
Cython/Compiler/Nodes.py

index ec11fd978e58db310b65cb4aef737431f0ff1e0b..cb279e07ce0bdb7c17aa2fdd70a674a26c137420 100644 (file)
@@ -1286,7 +1286,7 @@ class CCodeWriter(object):
         #    code = "((PyObject*)%s)" % code
         self.put_init_to_py_none(code, entry.type, nanny)
         if entry.in_closure:
-            self.put_giveref(code)
+            self.put_giveref('Py_None')
 
     def put_pymethoddef(self, entry, term, allow_skip=True):
         if entry.is_special or entry.name == '__getattribute__':
index ea4e42bd83ad753a3748bf0de856250182649e24..d3443036257171bb4fc1cfcb9f3108d782a95730 100644 (file)
@@ -2927,9 +2927,9 @@ class DefNode(FuncDefNode):
             if arg.needs_conversion:
                 self.generate_arg_conversion(arg, code)
             elif arg.entry.in_closure:
-                code.putln('%s = %s;' % (arg.entry.cname, arg.hdr_cname))
                 if arg.type.is_pyobject:
-                    code.put_var_incref(arg.entry)
+                    code.put_incref(arg.hdr_cname, py_object_type)
+                code.putln('%s = %s;' % (arg.entry.cname, arg.hdr_cname))
 
     def generate_arg_conversion(self, arg, code):
         # Generate conversion code for one argument.