Commit dfc47cd4 authored by Dmitry Trofimov's avatar Dmitry Trofimov

Fix "NoneType object is not callable" exception when using a tracing function...

Fix "NoneType object is not callable" exception when using a tracing function that returns None (#1769)

CPython uses the return value of tracing function to assign it to frame.f_trace field and then it uses it for the frame instead of tstate.c_tracefunc. If it is None, the context shouldn't be traced line by line.
parent a2db27bb
......@@ -198,7 +198,7 @@
PyThreadState *tstate; \
PyGILState_STATE state = PyGILState_Ensure(); \
tstate = PyThreadState_GET(); \
if (unlikely(tstate->use_tracing && tstate->c_tracefunc)) { \
if (unlikely(tstate->use_tracing && __pyx_frame->f_trace != Py_None)) { \
ret = __Pyx_call_line_trace_func(tstate, $frame_cname, lineno); \
} \
PyGILState_Release(state); \
......@@ -206,7 +206,7 @@
} \
} else { \
PyThreadState* tstate = PyThreadState_GET(); \
if (unlikely(tstate->use_tracing && tstate->c_tracefunc)) { \
if (unlikely(tstate->use_tracing && __pyx_frame->f_trace != Py_None)) { \
int ret = __Pyx_call_line_trace_func(tstate, $frame_cname, lineno); \
if (unlikely(ret)) goto_error; \
} \
......@@ -216,7 +216,7 @@
#define __Pyx_TraceLine(lineno, nogil, goto_error) \
if (likely(!__Pyx_use_tracing)); else { \
PyThreadState* tstate = PyThreadState_GET(); \
if (unlikely(tstate->use_tracing && tstate->c_tracefunc)) { \
if (unlikely(tstate->use_tracing && __pyx_frame->f_trace != Py_None)) { \
int ret = __Pyx_call_line_trace_func(tstate, $frame_cname, lineno); \
if (unlikely(ret)) goto_error; \
} \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment