Skip to content

Commit

Permalink
bpo-43472: Ensure PyInterpreterState_New audit events are raised when…
Browse files Browse the repository at this point in the history
… called through _xxsubinterpreters module (GH-25506)

(cherry picked from commit 7b86e47)

Co-authored-by: Steve Dower <steve.dower@python.org>
  • Loading branch information
miss-islington and zooba committed Apr 21, 2021
1 parent 303ffb7 commit 602eefe
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Doc/library/sys.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ always available.
.. function:: addaudithook(hook)

Append the callable *hook* to the list of active auditing hooks for the
current interpreter.
current (sub)interpreter.

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Ensures interpreter-level audit hooks receive the
``cpython.PyInterpreterState_New`` event when called through the
``_xxsubinterpreters`` module.
2 changes: 1 addition & 1 deletion Modules/_xxsubinterpretersmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1993,7 +1993,7 @@ interp_create(PyObject *self, PyObject *args)
}

// Create and initialize the new interpreter.
PyThreadState *save_tstate = PyThreadState_Swap(NULL);
PyThreadState *save_tstate = PyThreadState_Get();
// XXX Possible GILState issues?
PyThreadState *tstate = Py_NewInterpreter();
PyThreadState_Swap(save_tstate);
Expand Down

0 comments on commit 602eefe

Please sign in to comment.