mirror of
https://github.com/python/cpython.git
synced 2025-11-01 06:01:29 +00:00
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.
This commit is contained in:
parent
757891ee8a
commit
3831144f9c
2 changed files with 7 additions and 6 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue