]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-105716: Fix _PyInterpreterState_IsRunningMain() For Embedders (gh-117140)
authorEric Snow <ericsnowcurrently@gmail.com>
Fri, 22 Mar 2024 00:20:20 +0000 (18:20 -0600)
committerGitHub <noreply@github.com>
Fri, 22 Mar 2024 00:20:20 +0000 (18:20 -0600)
commitb3d25df8d38b79310587da54dbd88b06a16d4904
tree1daf220306410c2485f0bcfee557ddb0fce5022d
parentc4bf58a14f162557038a1535ca22c52b49d81d7b
gh-105716: Fix _PyInterpreterState_IsRunningMain() For Embedders (gh-117140)

When I added _PyInterpreterState_IsRunningMain() and friends last year, I tried to accommodate applications that embed Python but don't call _PyInterpreterState_SetRunningMain() (not that they're expected to).  That mostly worked fine until my recent changes in gh-117049, where the subtleties with the fallback code led to failures; the change ended up breaking test_tools.test_freeze, which exercises a basic embedding situation.

The simplest fix is to drop the fallback code I originally added to _PyInterpreterState_IsRunningMain() (and later to _PyThreadState_IsRunningMain()).  I've kept the fallback in the _xxsubinterpreters module though.  I've also updated Py_FrozenMain() to call _PyInterpreterState_SetRunningMain().
Modules/_xxsubinterpretersmodule.c
Python/frozenmain.c
Python/pystate.c