Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 785e65f

Browse files
Set running main in Py_FrozenMain().
1 parent 875e445 commit 785e65f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

Python/frozenmain.c

+9
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ Py_FrozenMain(int argc, char **argv)
5454
Py_ExitStatusException(status);
5555
}
5656

57+
PyInterpreterState *interp = PyInterpreterState_Get();
58+
if (_PyInterpreterState_SetRunningMain(interp) < 0) {
59+
PyErr_Print();
60+
exit(1);
61+
}
62+
5763
#ifdef MS_WINDOWS
5864
PyWinFreeze_ExeInit();
5965
#endif
@@ -83,6 +89,9 @@ Py_FrozenMain(int argc, char **argv)
8389
#ifdef MS_WINDOWS
8490
PyWinFreeze_ExeTerm();
8591
#endif
92+
93+
_PyInterpreterState_SetNotRunningMain(interp);
94+
8695
if (Py_FinalizeEx() < 0) {
8796
sts = 120;
8897
}

0 commit comments

Comments
 (0)