Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Switch to the main interpreter in clear_singlephase_extension().
  • Loading branch information
ericsnowcurrently committed Jul 8, 2024
commit 6e10c74f3c9c25fd8dd7e66788dadf6a4e7b6cc1
12 changes: 12 additions & 0 deletions Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -2153,9 +2153,21 @@ clear_singlephase_extension(PyInterpreterState *interp,
}
}

/* We must use the main interpreter to clean up the cache.
* See the note in import_run_extension(). */
PyThreadState *tstate = PyThreadState_GET();
PyThreadState *main_tstate = switch_to_main_interpreter(tstate);
if (main_tstate == NULL) {
return -1;
}

/* Clear the cached module def. */
_extensions_cache_delete(path, name);

if (main_tstate != tstate) {
switch_back_from_main_interpreter(tstate, main_tstate, NULL);
}

return 0;
}

Expand Down