Skip to content

Commit 7b86e47

Browse files
authored
bpo-43472: Ensure PyInterpreterState_New audit events are raised when called through _xxsubinterpreters module (GH-25506)
1 parent 139c232 commit 7b86e47

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

Doc/library/sys.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ always available.
2626
.. function:: addaudithook(hook)
2727

2828
Append the callable *hook* to the list of active auditing hooks for the
29-
current interpreter.
29+
current (sub)interpreter.
3030

3131
When an auditing event is raised through the :func:`sys.audit` function, each
3232
hook will be called in the order it was added with the event name and the
3333
tuple of arguments. Native hooks added by :c:func:`PySys_AddAuditHook` are
34-
called first, followed by hooks added in the current interpreter. Hooks
34+
called first, followed by hooks added in the current (sub)interpreter. Hooks
3535
can then log the event, raise an exception to abort the operation,
3636
or terminate the process entirely.
3737

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Ensures interpreter-level audit hooks receive the
2+
``cpython.PyInterpreterState_New`` event when called through the
3+
``_xxsubinterpreters`` module.

Modules/_xxsubinterpretersmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2025,7 +2025,7 @@ interp_create(PyObject *self, PyObject *args, PyObject *kwds)
20252025
}
20262026

20272027
// Create and initialize the new interpreter.
2028-
PyThreadState *save_tstate = PyThreadState_Swap(NULL);
2028+
PyThreadState *save_tstate = PyThreadState_Get();
20292029
// XXX Possible GILState issues?
20302030
PyThreadState *tstate = _Py_NewInterpreter(isolated);
20312031
PyThreadState_Swap(save_tstate);

0 commit comments

Comments
 (0)