summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2024-02-14 23:07:22 (GMT)
committerGitHub <noreply@github.com>2024-02-14 23:07:22 (GMT)
commit468430189d3ebe16f3067279f9be0fe82cdfadf6 (patch)
treeffb01d7698345c55dfa0cda5ddcca11a7655162f /Python
parent3e7b7df5cbaad5617cc28f0c005010787c48e6d6 (diff)
downloadcpython-468430189d3ebe16f3067279f9be0fe82cdfadf6.zip
cpython-468430189d3ebe16f3067279f9be0fe82cdfadf6.tar.gz
cpython-468430189d3ebe16f3067279f9be0fe82cdfadf6.tar.bz2
gh-115482: Assume the Main Interpreter is Always Running "main" (gh-115484)
This is a temporary fix to unblock embedders that do not call Py_Main(). _PyInterpreterState_IsRunningMain() will always return true for the main interpreter, even in corner cases where it technically should not. The (future) full solution will do the right thing in those corner cases.
Diffstat (limited to 'Python')
-rw-r--r--Python/pystate.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index 82c9558..08ec586 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -1044,7 +1044,14 @@ _PyInterpreterState_SetNotRunningMain(PyInterpreterState *interp)
int
_PyInterpreterState_IsRunningMain(PyInterpreterState *interp)
{
- return (interp->threads.main != NULL);
+ if (interp->threads.main != NULL) {
+ return 1;
+ }
+ // For now, we assume the main interpreter is always running.
+ if (_Py_IsMainInterpreter(interp)) {
+ return 1;
+ }
+ return 0;
}
int