Commits

Robert Kern committed 52fa2be

BUG: Work around the inability to use <object>NULL in recent Cythons.

Comments (0)

Files changed (4)

_line_profiler.pyx

     PY_LONG_LONG hpTimer()
     double hpTimerUnit()
 
+cdef extern from "unset_trace.h":
+    void unset_trace()
+
 
 def label(code):
     """ Return a (filename, first_lineno, func_name) tuple for a given code
 
     def disable(self):
         self.last_time = {}
-        PyEval_SetTrace(NULL, <object>NULL)
+        unset_trace()
 
     def get_stats(self):
         """ Return a LineStats object containing the timings.
     url = 'http://packages.python.org/line_profiler',
     ext_modules = [ 
         Extension('_line_profiler',
-                  sources=[line_profiler_source, 'timers.c'],
+                  sources=[line_profiler_source, 'timers.c', 'unset_trace.c'],
                   depends=['python25.pxd'],
         ),
     ],
+/* Hack to hide an <object>NULL from Cython. */
+
+#include "Python.h"
+
+void unset_trace() {
+    PyEval_SetTrace(NULL, NULL);
+}
+void unset_trace();
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.