Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Only call Python hooks when GIL is held
  • Loading branch information
zooba committed Nov 11, 2022
commit 09f0fdf0d6882573961a3de6d3ccf27924182e8f
3 changes: 2 additions & 1 deletion Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,8 @@ new_threadstate(PyInterpreterState *interp)
PyThreadState *tstate;
_PyRuntimeState *runtime = interp->runtime;

if (PySys_Audit("cpython.PyThreadState_New", NULL) < 0) {
PyThreadState *ts = _PyThreadState_GET();
if (ts && _PySys_Audit(ts, "cpython.PyThreadState_New", NULL) < 0) {
return NULL;
}

Expand Down
4 changes: 2 additions & 2 deletions Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ sys_audit_tstate(PyThreadState *ts, const char *event,
PyDTrace_AUDIT(event, (void *)eventArgs);
}

/* Call interpreter hooks */
if (is->audit_hooks) {
/* Call interpreter hooks if the GIL is held */
if (PyGILState_Check() && is->audit_hooks) {
Comment thread
zooba marked this conversation as resolved.
Outdated
eventName = PyUnicode_FromString(event);
if (!eventName) {
goto exit;
Expand Down