aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/pylifecycle.c
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2024-03-21 10:06:35 -0600
committerGitHub <noreply@github.com>2024-03-21 10:06:35 -0600
commit5a76d1be8ef371b75ca65166726923c249b5f615 (patch)
tree80a5b914c708d1ddce4da029b85e9d8c562ed0ee /Python/pylifecycle.c
parentbbee57fa8c318cb26d6c8651254927a1972c9738 (diff)
downloadcpython-5a76d1be8ef371b75ca65166726923c249b5f615.tar.gz
cpython-5a76d1be8ef371b75ca65166726923c249b5f615.zip
gh-105716: Update interp->threads.main After Fork (gh-117049)
I missed this in gh-109921. We also update Py_Exit() to call _PyInterpreterState_SetNotRunningMain(), if necessary.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r--Python/pylifecycle.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index bc76822e72c..4bd01ad23e5 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -3138,6 +3138,10 @@ call_ll_exitfuncs(_PyRuntimeState *runtime)
void _Py_NO_RETURN
Py_Exit(int sts)
{
+ PyThreadState *tstate = _PyThreadState_GET();
+ if (tstate != NULL && _PyThreadState_IsRunningMain(tstate)) {
+ _PyInterpreterState_SetNotRunningMain(tstate->interp);
+ }
if (Py_FinalizeEx() < 0) {
sts = 120;
}