From 07867367b853e6d9b2575828d6d6f191c99f766f Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Mon, 15 Apr 2024 10:36:46 -0600 Subject: [PATCH 1/2] Drop unused code. --- Lib/test/test_interpreters/test_api.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/Lib/test/test_interpreters/test_api.py b/Lib/test/test_interpreters/test_api.py index 9a7c7f2f92ef21..2bd8bee4063920 100644 --- a/Lib/test/test_interpreters/test_api.py +++ b/Lib/test/test_interpreters/test_api.py @@ -174,9 +174,6 @@ def test_idempotent(self): @requires_test_modules def test_created_with_capi(self): - last = 0 - for id, *_ in _interpreters.list_all(): - last = max(last, id) expected = _testinternalcapi.next_interpreter_id() text = self.run_temp_from_capi(f""" import {interpreters.__name__} as interpreters From c0e665b2e8c55311ddb8449e9482b73293ddb61d Mon Sep 17 00:00:00 2001 From: Eric Snow Date: Mon, 15 Apr 2024 18:16:42 -0600 Subject: [PATCH 2/2] Avoid importing test.support.os_helper in legacy interpreters. --- Lib/test/test_interpreters/utils.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Lib/test/test_interpreters/utils.py b/Lib/test/test_interpreters/utils.py index 08768c07c28ebf..8e475816f04de4 100644 --- a/Lib/test/test_interpreters/utils.py +++ b/Lib/test/test_interpreters/utils.py @@ -17,10 +17,13 @@ import warnings from test import support -from test.support import os_helper -from test.support import import_helper -_interpreters = import_helper.import_module('_xxsubinterpreters') +# We would use test.support.import_helper.import_module(), +# but the indirect import of test.support.os_helper causes refleaks. +try: + import _xxsubinterpreters as _interpreters +except ImportError as exc: + raise unittest.SkipTest(str(exc)) from test.support import interpreters @@ -399,6 +402,7 @@ def ensure_closed(fd): def temp_dir(self): tempdir = tempfile.mkdtemp() tempdir = os.path.realpath(tempdir) + from test.support import os_helper self.addCleanup(lambda: os_helper.rmtree(tempdir)) return tempdir