Skip to content

Commit 4684301

Browse files
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.
1 parent 3e7b7df commit 4684301

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Python/pystate.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,14 @@ _PyInterpreterState_SetNotRunningMain(PyInterpreterState *interp)
10441044
int
10451045
_PyInterpreterState_IsRunningMain(PyInterpreterState *interp)
10461046
{
1047-
return (interp->threads.main != NULL);
1047+
if (interp->threads.main != NULL) {
1048+
return 1;
1049+
}
1050+
// For now, we assume the main interpreter is always running.
1051+
if (_Py_IsMainInterpreter(interp)) {
1052+
return 1;
1053+
}
1054+
return 0;
10481055
}
10491056

10501057
int

0 commit comments

Comments
 (0)