]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-107471: Fix Refleaks in test_import (gh-107569)
authorEric Snow <ericsnowcurrently@gmail.com>
Wed, 2 Aug 2023 20:55:09 +0000 (14:55 -0600)
committerGitHub <noreply@github.com>
Wed, 2 Aug 2023 20:55:09 +0000 (20:55 +0000)
commit017f047183fa33743f7e36c5c360f5c670032be3
treea0afb9c5b2019c9638c6b4d37ff4974ad0940230
parentbcdd3072316181b49d94567bb648825a07ca9ae1
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.)
Lib/test/test_import/__init__.py
Python/import.c