Refnanny cleanup and bugfix.
authorDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Wed, 7 Jan 2009 13:42:44 +0000 (14:42 +0100)
committerDag Sverre Seljebotn <dagss@student.matnat.uio.no>
Wed, 7 Jan 2009 13:42:44 +0000 (14:42 +0100)
Cython/Compiler/Code.py
Cython/Compiler/ModuleNode.py
Cython/Compiler/Nodes.py
Cython/Runtime/build.sh

index 8a4b61c11eeb01996c8d6c51049dd28ae0b4d289..f4f155b7aeea639b5f73768645a646904467dae7 100644 (file)
@@ -744,6 +744,9 @@ class CCodeWriter(object):
     def put_giveref(self, cname):
         self.putln("__Pyx_GIVEREF(%s);" % cname)
     
+    def put_xgiveref(self, cname):
+        self.putln("__Pyx_XGIVEREF(%s);" % cname)
+
     def put_incref(self, cname, type):
         self.putln("__Pyx_INCREF(%s);" % self.as_pyobject(cname, type))
     
index 14ba4122a91d18441c70b80b9fd21ac38a236ccc..353ab7b62547be4264944721cf0fd00f785cd0fe 100644 (file)
@@ -2321,7 +2321,6 @@ bad:
         
 refcount_utility_code = UtilityCode(proto="""
 #ifdef CYTHON_REFNANNY
-
 void __Pyx_Refnanny_INCREF(void*, PyObject*, int);
 void __Pyx_Refnanny_GOTREF(void*, PyObject*, int);
 void __Pyx_Refnanny_GIVEREF(void*, PyObject*, int);
@@ -2329,7 +2328,6 @@ void __Pyx_Refnanny_INCREF(void*, PyObject*, int);
 void __Pyx_Refnanny_DECREF(void*, PyObject*, int);
 void* __Pyx_Refnanny_NewContext(char*, int);
 int __Pyx_Refnanny_FinishContext(void*);
-
 #define __Pyx_INCREF(r) __Pyx_Refnanny_INCREF(__pyx_refchk, r, __LINE__)
 #define __Pyx_GOTREF(r) __Pyx_Refnanny_GOTREF(__pyx_refchk, r, __LINE__)
 #define __Pyx_GIVEREF(r) __Pyx_Refnanny_GIVEREF(__pyx_refchk, r, __LINE__)
@@ -2338,9 +2336,7 @@ int __Pyx_Refnanny_FinishContext(void*);
 #define __Pyx_SetupRefcountContext(name) \
   void* __pyx_refchk = __Pyx_Refnanny_NewContext(name, __LINE__)
 #define __Pyx_FinishRefcountContext() __Pyx_Refnanny_FinishContext(__pyx_refchk)
-
 #else
-
 #define __Pyx_INCREF(r) Py_INCREF(r)
 #define __Pyx_GOTREF(r)
 #define __Pyx_GIVEREF(r)
@@ -2348,6 +2344,6 @@ int __Pyx_Refnanny_FinishContext(void*);
 #define __Pyx_XDECREF(r) Py_XDECREF(r)
 #define __Pyx_SetupRefcountContext(name)
 #define __Pyx_FinishRefcountContext() 0
-
 #endif /* CYTHON_REFNANNY */
+#define __Pyx_XGIVEREF(r) (r ? __Pyx_GIVEREF(r) : 0)
 """)
index 38ac2cca1ea65e7117f4622057974fbe650a825a..7efc68374b2bcf34af13c5e3cc78659ef2b21b07 100644 (file)
@@ -1142,7 +1142,7 @@ class FuncDefNode(StatNode, BlockNode):
         if err_val is None and default_retval:
             err_val = default_retval
         if self.return_type.is_pyobject:
-            code.put_giveref(Naming.retval_cname)
+            code.put_xgiveref(Naming.retval_cname)
         if err_val is None:
             code.putln('__Pyx_FinishRefcountContext();')
         else:
index 7f369b91f1e93f60e7a2c16d3f8814c5b778a40d..7fbea4200f60877c02a6b94bcc177c6de9948f41 100755 (executable)
@@ -1,21 +1,9 @@
-cat <<EOF > ../../Cython/Compiler/DebugFlags.py
-debug_disposal_code = 0
-debug_temp_alloc = 0
-debug_coercion = 0
-
-debug_refnanny = 0
-EOF
+# Temporary hacky script, should be replaced
+# with distutils-based solution.
 
+PYTHONINC=/local/include/python2.5
 
 python ../../cython.py refnanny.pyx
 gcc -shared -pthread -fPIC -fwrapv -O2 -Wall \
-  -fno-strict-aliasing -I/local/include/python2.5 \
+  -fno-strict-aliasing -I$PYTHONINC \
   -o refnanny.so -I. refnanny.c
-
-cat <<EOF > ../../Cython/Compiler/DebugFlags.py
-debug_disposal_code = 0
-debug_temp_alloc = 0
-debug_coercion = 0
-
-debug_refnanny = 1
-EOF