Skip to content

Commit 3831144

Browse files
gh-76785: Fix Windows Refleak in test_interpreters (gh-117913)
gh-117662 introduced some refleaks, or, rather, exposed some existing refleaks. The leaks are coming when test.support.os_helper is imported in a "legacy" interpreter. I've updated test.test_interpreters.utils to avoid importing os_helper, which fixes the leaks. I'll address the root cause separately.
1 parent 757891e commit 3831144

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

Lib/test/test_interpreters/test_api.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,6 @@ def test_idempotent(self):
174174

175175
@requires_test_modules
176176
def test_created_with_capi(self):
177-
last = 0
178-
for id, *_ in _interpreters.list_all():
179-
last = max(last, id)
180177
expected = _testinternalcapi.next_interpreter_id()
181178
text = self.run_temp_from_capi(f"""
182179
import {interpreters.__name__} as interpreters

Lib/test/test_interpreters/utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,13 @@
1717
import warnings
1818

1919
from test import support
20-
from test.support import os_helper
21-
from test.support import import_helper
2220

23-
_interpreters = import_helper.import_module('_xxsubinterpreters')
21+
# We would use test.support.import_helper.import_module(),
22+
# but the indirect import of test.support.os_helper causes refleaks.
23+
try:
24+
import _xxsubinterpreters as _interpreters
25+
except ImportError as exc:
26+
raise unittest.SkipTest(str(exc))
2427
from test.support import interpreters
2528

2629

@@ -399,6 +402,7 @@ def ensure_closed(fd):
399402
def temp_dir(self):
400403
tempdir = tempfile.mkdtemp()
401404
tempdir = os.path.realpath(tempdir)
405+
from test.support import os_helper
402406
self.addCleanup(lambda: os_helper.rmtree(tempdir))
403407
return tempdir
404408

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy