mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
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().
This commit is contained in:
parent
c4bf58a14f
commit
b3d25df8d3
3 changed files with 39 additions and 22 deletions
|
@ -54,6 +54,12 @@ Py_FrozenMain(int argc, char **argv)
|
|||
Py_ExitStatusException(status);
|
||||
}
|
||||
|
||||
PyInterpreterState *interp = PyInterpreterState_Get();
|
||||
if (_PyInterpreterState_SetRunningMain(interp) < 0) {
|
||||
PyErr_Print();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
#ifdef MS_WINDOWS
|
||||
PyWinFreeze_ExeInit();
|
||||
#endif
|
||||
|
@ -83,6 +89,9 @@ Py_FrozenMain(int argc, char **argv)
|
|||
#ifdef MS_WINDOWS
|
||||
PyWinFreeze_ExeTerm();
|
||||
#endif
|
||||
|
||||
_PyInterpreterState_SetNotRunningMain(interp);
|
||||
|
||||
if (Py_FinalizeEx() < 0) {
|
||||
sts = 120;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue