Skip to content

Commit c78cef1

Browse files
Remove old workarounds from subprocess_Popen
1 parent fb8842b commit c78cef1

File tree

2 files changed

+1
-22
lines changed

2 files changed

+1
-22
lines changed

Diff for: pytensor/utils.py

+1-21
Original file line numberDiff line numberDiff line change
@@ -137,34 +137,14 @@ def subprocess_Popen(command: str | list[str], **params):
137137
except AttributeError:
138138
startupinfo.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW # type: ignore[attr-defined]
139139

140-
# Anaconda for Windows does not always provide .exe files
141-
# in the PATH, they also have .bat files that call the corresponding
142-
# executable. For instance, "g++.bat" is in the PATH, not "g++.exe"
143-
# Unless "shell=True", "g++.bat" is not executed when trying to
144-
# execute "g++" without extensions.
145-
# (Executing "g++.bat" explicitly would also work.)
146-
params["shell"] = True
147140
# "If shell is True, it is recommended to pass args as a string rather than as a sequence." (cite taken from https://docs.python.org/2/library/subprocess.html#frequently-used-arguments)
148141
# In case when command arguments have spaces, passing a command as a list will result in incorrect arguments break down, and consequently
149142
# in "The filename, directory name, or volume label syntax is incorrect" error message.
150143
# Passing the command as a single string solves this problem.
151144
if isinstance(command, list):
152145
command = " ".join(command)
153146

154-
# Using the dummy file descriptors below is a workaround for a
155-
# crash experienced in an unusual Python 2.4.4 Windows environment
156-
# with the default None values.
157-
stdin = None
158-
if "stdin" not in params:
159-
stdin = Path(os.devnull).open()
160-
params["stdin"] = stdin.fileno()
161-
162-
try:
163-
proc = subprocess.Popen(command, startupinfo=startupinfo, **params)
164-
finally:
165-
if stdin is not None:
166-
stdin.close()
167-
return proc
147+
return subprocess.Popen(command, startupinfo=startupinfo, **params)
168148

169149

170150
def call_subprocess_Popen(command, **params):

Diff for: tests/compile/function/test_function.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import pickle
2-
import re
32
import shutil
43
import tempfile
54
from pathlib import Path

0 commit comments

Comments
 (0)