]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43472: Ensure PyInterpreterState_New audit events are raised when called through...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 21 Apr 2021 22:53:31 +0000 (15:53 -0700)
committerGitHub <noreply@github.com>
Wed, 21 Apr 2021 22:53:31 +0000 (15:53 -0700)
(cherry picked from commit 7b86e47617d81a4b14d929743425f448971e8c86)

Co-authored-by: Steve Dower <steve.dower@python.org>
Doc/library/sys.rst
Misc/NEWS.d/next/Security/2021-04-21-22-53-31.bpo-43472.gjLBTb.rst [new file with mode: 0644]
Modules/_xxsubinterpretersmodule.c

index def2d7ea63dcf1a196b7aec0dd4173ae8736253e..95cbaf2f033ea110f957dadec8e97a1a9a678e6f 100644 (file)
@@ -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.
 
diff --git a/Misc/NEWS.d/next/Security/2021-04-21-22-53-31.bpo-43472.gjLBTb.rst b/Misc/NEWS.d/next/Security/2021-04-21-22-53-31.bpo-43472.gjLBTb.rst
new file mode 100644 (file)
index 0000000..e38dc16
--- /dev/null
@@ -0,0 +1,3 @@
+Ensures interpreter-level audit hooks receive the
+``cpython.PyInterpreterState_New`` event when called through the
+``_xxsubinterpreters`` module.
index db1116ac6e352dcb7ea4a41f5f046fea89909679..bda2a256ed9f7b2387a4c87534784acdd4f121f4 100644 (file)
@@ -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);