Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions Lib/test/test_audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,11 @@ def test_threading(self):
actual = [(ev[0], ev[2]) for ev in events]
expected = [
("_thread.start_new_thread", "(<test_func>, (), None)"),
("cpython.PyThreadState_New", "(2,)"),
("test.test_func", "()"),
("cpython.PyThreadState_Clear", "(2,)"),
]

self.assertEqual(actual, expected)

def test_threading_abort(self):
# Ensures that aborting PyThreadState_New raises the correct exception
returncode, events, stderr = self.run_python("test_threading_abort")
if returncode:
self.fail(stderr)


def test_wmi_exec_query(self):
import_helper.import_module("_wmi")
Expand Down
19 changes: 1 addition & 18 deletions Python/pystate.c
Original file line number Diff line number Diff line change
Expand Up @@ -875,27 +875,14 @@ PyThreadState_New(PyInterpreterState *interp)
PyThreadState *tstate = new_threadstate(interp);
if (tstate) {
_PyThreadState_SetCurrent(tstate);
if (PySys_Audit("cpython.PyThreadState_New", "K", tstate->id) < 0) {
PyThreadState_Clear(tstate);
_PyThreadState_DeleteCurrent(tstate);
return NULL;
}
}
return tstate;
}

PyThreadState *
_PyThreadState_Prealloc(PyInterpreterState *interp)
{
PyThreadState *tstate = new_threadstate(interp);
if (tstate) {
if (PySys_Audit("cpython.PyThreadState_New", "K", tstate->id) < 0) {
PyThreadState_Clear(tstate);
_PyThreadState_Delete(tstate, 0);
return NULL;
}
}
return tstate;
return new_threadstate(interp);
}

// We keep this around for (accidental) stable ABI compatibility.
Expand Down Expand Up @@ -1043,10 +1030,6 @@ _PyInterpreterState_ClearModules(PyInterpreterState *interp)
void
PyThreadState_Clear(PyThreadState *tstate)
{
if (PySys_Audit("cpython.PyThreadState_Clear", "K", tstate->id) < 0) {
PyErr_WriteUnraisable(NULL);
}

int verbose = _PyInterpreterState_GetConfig(tstate->interp)->verbose;

if (verbose && tstate->cframe->current_frame != NULL) {
Expand Down