Skip to content

Commit 0604d9d

Browse files
Use subprocess.DEVNULL.
1 parent 0b06350 commit 0604d9d

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

Lib/test/test_xpickle.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -69,19 +69,18 @@ def have_python_version(py_version):
6969
python_str = ".".join(map(str, py_version))
7070
targets = [('py', f'-{python_str}'), (f'python{python_str}',)]
7171
if py_version not in py_executable_map:
72-
with open(os.devnull, 'w') as devnull:
73-
for target in targets[0 if is_windows else 1:]:
74-
try:
75-
worker = subprocess.Popen([*target, '-c','import test.support'],
76-
stdout=devnull,
77-
stderr=devnull,
78-
shell=is_windows)
79-
worker.communicate()
80-
if worker.returncode == 0:
81-
py_executable_map[py_version] = target
82-
break
83-
except FileNotFoundError:
84-
pass
72+
for target in targets[0 if is_windows else 1:]:
73+
try:
74+
worker = subprocess.Popen([*target, '-c','import test.support'],
75+
stdout=subprocess.DEVNULL,
76+
stderr=subprocess.DEVNULL,
77+
shell=is_windows)
78+
worker.communicate()
79+
if worker.returncode == 0:
80+
py_executable_map[py_version] = target
81+
break
82+
except FileNotFoundError:
83+
pass
8584

8685
return py_executable_map.get(py_version, None)
8786

0 commit comments

Comments
 (0)