GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||
GeezerVison is showing github.com — gh-117953: Always Run Extension Init Func in Main Interpreter First by ericsnowcurrently · Pull Request #118157 · python/cpython Conversation
| |||||||||||||||||||||||
|
FYI, there's a refleak somewhere in here that I'm tracking down. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Nothing jumps out at me looking like a refleak, unfortunately. Possible the first import is leaking something in the main interpreter and it's not being counted right in the subinterpreter? (Or vice versa)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * and then continue loading like normal. */ | ||
|
|
||
| PyThreadState *main_tstate = NULL; | ||
| if (!_Py_IsMainInterpreter(tstate->interp)) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary if switch_to_main_interpreter is doing the same check?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It isn't necessary, but I wanted to be explicit about it. I'll see about cleaning that up.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
fixed
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @@ -1941,15 +2005,73 @@ import_run_extension(PyThreadState *tstate, PyModInitFunction p0, | |||
| if (cached == NULL) { | |||
| goto error; | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can we do this without switching back?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I noticed that too and have already fixed it locally. 😄
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
fixed
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…irst (pythongh-118157) This change makes sure all extension/builtin modules have their init function run first by the main interpreter before proceeding with import in the original interpreter (main or otherwise). This means when the import of a single-phase init module fails in an isolated subinterpreter, it won't tie any global state/callbacks to the subinterpreter.
pythongh-121503) The change in pythongh-118157 (b2cd54a) should have also updated clear_singlephase_extension() but didn't. We fix that here. Note that clear_singlephase_extension() (AKA _PyImport_ClearExtension()) is only used in tests. (cherry picked from commit 15d48ae) Co-authored-by: Eric Snow <[email protected]>
…ds (gh-121517) The change in gh-118157 (b2cd54a) should have also updated clear_singlephase_extension() but didn't. We fix that here. Note that clear_singlephase_extension() (AKA _PyImport_ClearExtension()) is only used in tests. (cherry picked from commit 15d48ae, AKA gh-121503) Co-authored-by: Eric Snow <[email protected]>
pythongh-121503) The change in pythongh-118157 (b2cd54a) should have also updated clear_singlephase_extension() but didn't. We fix that here. Note that clear_singlephase_extension() (AKA _PyImport_ClearExtension()) is only used in tests.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.