Skip to content

Commit 0f0c305

Browse files
Do not switch if already on the main interpreter.
1 parent 0560cac commit 0f0c305

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Python/import.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,10 @@ static PyThreadState *
11591159
maybe_switch_to_main_interpreter(PyThreadState *tstate)
11601160
{
11611161
PyThreadState *main_tstate = tstate;
1162-
if (check_multi_interp_extensions(tstate->interp)) {
1162+
if (_Py_IsMainInterpreter(tstate->interp)) {
1163+
/* There's no need to switch. */
1164+
}
1165+
else if (check_multi_interp_extensions(tstate->interp)) {
11631166
/*
11641167
If the module is single-phase init then the import will fail.
11651168
However, the module's init function will still get run.

0 commit comments

Comments
 (0)