aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index ad9be714c02..5e663c17c79 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -256,8 +256,7 @@ sys_audit_tstate(PyThreadState *ts, const char *event,
}
/* Disallow tracing in hooks unless explicitly enabled */
- ts->tracing++;
- ts->cframe->use_tracing = 0;
+ PyThreadState_EnterTracing(ts);
while ((hook = PyIter_Next(hooks)) != NULL) {
_Py_IDENTIFIER(__cantrace__);
PyObject *o;
@@ -270,14 +269,12 @@ sys_audit_tstate(PyThreadState *ts, const char *event,
break;
}
if (canTrace) {
- ts->cframe->use_tracing = (ts->c_tracefunc || ts->c_profilefunc) ? 255 : 0;
- ts->tracing--;
+ PyThreadState_LeaveTracing(ts);
}
PyObject* args[2] = {eventName, eventArgs};
o = _PyObject_FastCallTstate(ts, hook, args, 2);
if (canTrace) {
- ts->tracing++;
- ts->cframe->use_tracing = 0;
+ PyThreadState_EnterTracing(ts);
}
if (!o) {
break;
@@ -285,8 +282,7 @@ sys_audit_tstate(PyThreadState *ts, const char *event,
Py_DECREF(o);
Py_CLEAR(hook);
}
- ts->cframe->use_tracing = (ts->c_tracefunc || ts->c_profilefunc) ? 255 : 0;
- ts->tracing--;
+ PyThreadState_LeaveTracing(ts);
if (_PyErr_Occurred(ts)) {
goto exit;
}