summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSteve Dower <steve.dower@python.org>2022-11-16 17:15:52 (GMT)
committerGitHub <noreply@github.com>2022-11-16 17:15:52 (GMT)
commit19c1462e8dca3319c8290e2edcce482bd18cb018 (patch)
tree01d4d3189f912b0444faf55a44e34057e8dc5afb /Modules
parent01fa907aa8e7c475a76b407f35c635b26c9f47f8 (diff)
downloadcpython-19c1462e8dca3319c8290e2edcce482bd18cb018.zip
cpython-19c1462e8dca3319c8290e2edcce482bd18cb018.tar.gz
cpython-19c1462e8dca3319c8290e2edcce482bd18cb018.tar.bz2
gh-99377: Add audit events for thread creation and clear (GH-99378)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_threadmodule.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c
index 5968d4e..ec8b6d8 100644
--- a/Modules/_threadmodule.c
+++ b/Modules/_threadmodule.c
@@ -1145,6 +1145,11 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
return NULL;
}
+ if (PySys_Audit("_thread.start_new_thread", "OOO",
+ func, args, kwargs ? kwargs : Py_None) < 0) {
+ return NULL;
+ }
+
PyInterpreterState *interp = _PyInterpreterState_GET();
if (!_PyInterpreterState_HasFeature(interp, Py_RTFLAGS_THREADS)) {
PyErr_SetString(PyExc_RuntimeError,
@@ -1160,7 +1165,10 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
boot->tstate = _PyThreadState_Prealloc(boot->interp);
if (boot->tstate == NULL) {
PyMem_Free(boot);
- return PyErr_NoMemory();
+ if (!PyErr_Occurred()) {
+ return PyErr_NoMemory();
+ }
+ return NULL;
}
boot->runtime = runtime;
boot->func = Py_NewRef(func);