From 8adcde5d86fd07b116e8b872e9688bfec7d7056f Mon Sep 17 00:00:00 2001 From: sobolevn Date: Wed, 22 Jul 2026 19:29:45 +0300 Subject: [PATCH] gh-154431: Use existing `runtime->audit_hooks.mutex` instead of a new one --- Include/internal/pycore_interp_structs.h | 1 - Python/pystate.c | 1 - Python/sysmodule.c | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Include/internal/pycore_interp_structs.h b/Include/internal/pycore_interp_structs.h index 3d577ff717cc6e1..0623adce693d465 100644 --- a/Include/internal/pycore_interp_structs.h +++ b/Include/internal/pycore_interp_structs.h @@ -977,7 +977,6 @@ struct _is { struct _obmalloc_state *obmalloc; PyObject *audit_hooks; - PyMutex audit_hooks_mutex; PyType_WatchCallback type_watchers[TYPE_MAX_WATCHERS]; PyCode_WatchCallback code_watchers[CODE_MAX_WATCHERS]; PyContext_WatchCallback context_watchers[CONTEXT_MAX_WATCHERS]; diff --git a/Python/pystate.c b/Python/pystate.c index b6c34552e94337b..d10b38def32911d 100644 --- a/Python/pystate.c +++ b/Python/pystate.c @@ -578,7 +578,6 @@ init_interpreter(PyInterpreterState *interp, llist_init(&interp->mem_free_queue.head); llist_init(&interp->asyncio_tasks_head); interp->asyncio_tasks_lock = (PyMutex){0}; - interp->audit_hooks_mutex = (PyMutex){0}; for (int i = 0; i < _PY_MONITORING_UNGROUPED_EVENTS; i++) { interp->monitors.tools[i] = 0; } diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 207ccbce41d71db..d88d51dd266c1c2 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -537,7 +537,7 @@ sys_addaudithook_impl(PyObject *module, PyObject *hook) } PyInterpreterState *interp = tstate->interp; - PyMutex mutex = interp->audit_hooks_mutex; + PyMutex mutex = interp->runtime->audit_hooks.mutex; PyMutex_Lock(&mutex); if (interp->audit_hooks == NULL) {