diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2023-08-02 20:55:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-02 20:55:09 (GMT) |
commit | 017f047183fa33743f7e36c5c360f5c670032be3 (patch) | |
tree | a0afb9c5b2019c9638c6b4d37ff4974ad0940230 /Python | |
parent | bcdd3072316181b49d94567bb648825a07ca9ae1 (diff) | |
download | cpython-017f047183fa33743f7e36c5c360f5c670032be3.zip cpython-017f047183fa33743f7e36c5c360f5c670032be3.tar.gz cpython-017f047183fa33743f7e36c5c360f5c670032be3.tar.bz2 |
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.)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/import.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/Python/import.c b/Python/import.c index 3be2f76..56b2dc1 100644 --- a/Python/import.c +++ b/Python/import.c @@ -1073,6 +1073,7 @@ _extensions_cache_delete(PyObject *filename, PyObject *name) However, this decref would be problematic if the module def were dynamically allocated, it were the last ref, and this function were called with an interpreter other than the def's owner. */ + assert(_Py_IsImmortal(entry->value)); entry->value = NULL; finally: |