bpo-43472: Ensure PyInterpreterState_New audit events are raised when… · python/cpython@602eefe

File tree

3 files changed

lines changed

  • Misc/NEWS.d/next/Security

3 files changed

lines changed

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
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.

Original file line numberDiff line numberDiff line change

@@ -1993,7 +1993,7 @@ interp_create(PyObject *self, PyObject *args)

19931993

}

19941994
19951995

// Create and initialize the new interpreter.

1996-

PyThreadState *save_tstate = PyThreadState_Swap(NULL);

1996+

PyThreadState *save_tstate = PyThreadState_Get();

19971997

// XXX Possible GILState issues?

19981998

PyThreadState *tstate = Py_NewInterpreter();

19991999

PyThreadState_Swap(save_tstate);