bpo-35943: PyImport_GetModule() can return partially-initialized module#15057
bpo-35943: PyImport_GetModule() can return partially-initialized module#15057brettcannon merged 11 commits into
Conversation
gnprice
left a comment
There was a problem hiding this comment.
This feels like a somewhat tricky bit of logic that it'd be best not to duplicate.
How about pulling it out from PyImport_ImportModuleLevelObject as its own function? I think I'd take the whole body of the if (mod != NULL ...) block. A good description of what it means might be "ensure initialized", so perhaps spelled import_ensure_initialized.
(I'd make it a static function, so it isn't visible outside this file -- that avoids any need to worry about the API.)
Then this function here only needs to add a couple of lines, invoking that one.
Sorry, something went wrong.
gnprice
left a comment
There was a problem hiding this comment.
Thanks @nanjekyejoannah for the update! I think this refactor worked out very well.
Sorry, something went wrong.
|
@gnprice and @serhiy-storchaka, I have made some changes PTAL. |
Sorry, something went wrong.
gnprice
left a comment
There was a problem hiding this comment.
LGTM! Thanks @nanjekyejoannah for this patch, and for all the updates.
Sorry, something went wrong.
Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com>
Co-Authored-By: Serhiy Storchaka <storchaka@gmail.com>
|
I have made the requested changes @ericsnowcurrently , @serhiy-storchaka , @gnprice PTAL . |
Sorry, something went wrong.
|
@nanjekyejoannah FYI you forgot to use the phrase "I have made the requested changes; please review again" to tell the bot to flag this PR as ready for re-review. I'll go ahead and do the label change manually. |
Sorry, something went wrong.
My bad. Thanks for the reminder. |
Sorry, something went wrong.
|
Thanks for making the requested changes! @serhiy-storchaka, @ericsnowcurrently: please review the changes made to this pull request. |
Sorry, something went wrong.
|
I didn't follow this change closely. When I look at the final merged change, it looks simple. But here I see a long discussion, which makes me understand that writing this change was quite difficult. So, well done Joannah for helping to make Python more correct ✨ 🍰 ✨ ;-) |
Sorry, something went wrong.
|
Thanks @nanjekyejoannah for the PR, and @brettcannon for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7. |
Sorry, something went wrong.
|
Sorry, @nanjekyejoannah and @brettcannon, I could not cleanly backport this to |
Sorry, something went wrong.
Added optimization to prevent
PyImport_GetModule()from returning partially-initialized module.https://bugs.python.org/issue35943