-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-104621: Check for Incompatible Extensions in import_find_extension() #107184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gh-104621: Check for Incompatible Extensions in import_find_extension() #107184
Conversation
@erlend-aasland any objections? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took me a while to figure out all the different paths in _imp_create_dynamic_impl
and import_find_extension
😄
Yeah, it's a beast. I've tried to add some useful notes in import.c. |
Thanks @ericsnowcurrently for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12. |
GH-107360 is a backport of this pull request to the 3.12 branch. |
…ension() (pythongh-107184) This fixes a bug where incompatible modules could still be imported if attempted multiple times. (cherry picked from commit 75c974f) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
…tension() (gh-107184) (gh-107360) gh-104621: Check for Incompatible Extensions in import_find_extension() (gh-107184) This fixes a bug where incompatible modules could still be imported if attempted multiple times. (cherry picked from commit 75c974f) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
It leaks ref. #107471 |
gh-107184 introduced a refleak in test_import.SubinterpImportTests (specifically test_singlephase_check_with_setting_and_override and test_single_init_extension_compat). We fix it here by making sure _testsinglephase is removed from sys.modules whenever we clear the runtime's internal state for the module. The underlying problem is strictly contained in the internal function _PyImport_ClearExtension() (AKA _testinternalcapi.clear_extension()), which is only used in tests. (This also fixes an intermittent segfault introduced in the same place, in test_disallowed_reimport.)
pythongh-107184 introduced a refleak in test_import.SubinterpImportTests (specifically test_singlephase_check_with_setting_and_override and test_single_init_extension_compat). We fix it here by making sure _testsinglephase is removed from sys.modules whenever we clear the runtime's internal state for the module. The underlying problem is strictly contained in the internal function _PyImport_ClearExtension() (AKA _testinternalcapi.clear_extension()), which is only used in tests. (This also fixes an intermittent segfault introduced in the same place, in test_disallowed_reimport.) (cherry picked from commit 017f047) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
gh-107471: Fix Refleaks in test_import (gh-107569) gh-107184 introduced a refleak in test_import.SubinterpImportTests (specifically test_singlephase_check_with_setting_and_override and test_single_init_extension_compat). We fix it here by making sure _testsinglephase is removed from sys.modules whenever we clear the runtime's internal state for the module. The underlying problem is strictly contained in the internal function _PyImport_ClearExtension() (AKA _testinternalcapi.clear_extension()), which is only used in tests. (This also fixes an intermittent segfault introduced in the same place, in test_disallowed_reimport.) (cherry picked from commit 017f047) Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
This fixes a bug where incompatible modules could still be imported if attempted multiple times.