8000 gh-104621: Check for Incompatible Extensions in import_find_extension() by ericsnowcurrently · Pull Request #107184 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

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

Merged

Conversation

ericsnowcurrently
Copy link
Member
@ericsnowcurrently ericsnowcurrently commented Jul 24, 2023

This fixes a bug where incompatible modules could still be imported if attempted multiple times.

@brettcannon brettcannon removed their request for review July 26, 2023 18:16
@ericsnowcurrently
Copy link
Member Author

@erlend-aasland any objections?

Copy link
Contributor
@erlend-aasland erlend-aasland left a 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 😄

@ericsnowcurrently
Copy link
Member Author

Yeah, it's a beast. I've tried to add some useful notes in import.c.

@ericsnowcurrently ericsnowcurrently merged commit 75c974f into python:main Jul 27, 2023
@miss-islington
Copy link
Contributor

Thanks @ericsnowcurrently for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-107360 is a backport of this pull request to the 3.12 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 27, 2023
…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>
@bedevere-bot bedevere-bot removed the needs backport to 3.12 only security fixes label Jul 27, 2023
@ericsnowcurrently ericsnowcurrently deleted the fix-disallowed-reimport branch July 27, 2023 21:08
ericsnowcurrently added a commit that referenced this pull request Jul 27, 2023
…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>
@sunmy2019
Copy link
Member

It leaks ref. #107471

ericsnowcurrently added a commit that referenced this pull request Aug 2, 2023
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.)
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Aug 2, 2023
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>
Yhg1s pushed a commit that referenced this pull request Aug 2, 2023
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0