Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
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
PySys_AddAuditHook: check initialized, not core_initialized
The docs say audit hooks are notified "after runtime initialization".
With the flag move, initialized=0 throughout init (including site
import), so hooks are correctly not invoked during any init phase.
Using core_initialized would have expanded the invocation window
beyond the original behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
  • Loading branch information
gpshead and claude committed Mar 22, 2026
commit 3e1eedd470b7b2dd70fecdc6861d7027ca1eb27a
4 changes: 2 additions & 2 deletions Python/sysmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Data members:
#include "pycore_pymath.h" // _PY_SHORT_FLOAT_REPR
#include "pycore_pymem.h" // _PyMem_DefaultRawFree()
#include "pycore_pystate.h" // _PyThreadState_GET()
#include "pycore_runtime.h" // _PyRuntimeState_GetCoreInitialized()
#include "pycore_runtime.h" // _PyRuntimeState_GetInitialized()
Comment thread
gpshead marked this conversation as resolved.
Outdated
#include "pycore_pystats.h" // _Py_PrintSpecializationStats()
#include "pycore_structseq.h" // _PyStructSequence_InitBuiltinWithFlags()
#include "pycore_sysmodule.h" // export _PySys_GetSizeOf()
Expand Down Expand Up @@ -472,7 +472,7 @@ PySys_AddAuditHook(Py_AuditHookFunction hook, void *userData)
PySys_AddAuditHook() can be called before Python is initialized. */
_PyRuntimeState *runtime = &_PyRuntime;
PyThreadState *tstate;
if (_PyRuntimeState_GetCoreInitialized(runtime)) {
if (_PyRuntimeState_GetInitialized(runtime)) {
tstate = _PyThreadState_GET();
}
else {
Expand Down
Loading