8000 Avoid importing test.support.os_helper in legacy interpreters. · python/cpython@c0e665b · GitHub
[go: up one dir, main page]

Skip to content

Commit c0e665b

Browse files
Avoid importing test.support.os_helper in legacy interpreters.
1 parent 0786736 commit c0e665b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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)
0