File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -1077,6 +1077,9 @@ def test_popen_file_not_found():
10771077 tmp_fd , tmp_path = tempfile .mkstemp (prefix = "tmp-python" )
10781078 os .close (tmp_fd )
10791079 os .remove (tmp_path )
1080- with pytest .raises (FileNotFoundError , match = rf"Could not find '{ tmp_path } '" ):
1080+ with pytest .raises (
1081+ FileNotFoundError ,
1082+ match = r"provide an absolute path to an existing installation to popen" ,
1083+ ):
10811084 with popen ([tmp_path ]):
10821085 pass
Original file line number Diff line number Diff line change @@ -1201,7 +1201,21 @@ def popen(
12011201 executable_path = args [0 ]
12021202 if not os .path .isabs (executable_path ):
12031203 executable_path = os .path .join (sysconfig .get_path ("scripts" ), executable_path )
1204- if not os .path .isfile (executable_path ):
1204+
1205+ # On Windows, it's valid to start a process using only '{program-name}' and Windows will
1206+ # automatically find and execute '{program-name}.exe'.
1207+ #
1208+ # That allows e.g. `popen(["dask-worker"])` to work despite the installed file being called 'dask-worker.exe'.
1209+ #
1210+ # docs: https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw
1211+ #
1212+ if WINDOWS :
1213+ executable_exists = os .path .isfile (executable_path ) or os .path .isfile (
1214+ f"{ executable_path } .exe"
1215+ )
1216+ else :
1217+ executable_exists = os .path .isfile (executable_path )
1218+ if not executable_exists :
12051219 raise FileNotFoundError (
12061220 f"Could not find '{ executable_path } '. To avoid this warning, provide an absolute path to an existing installation to popen()."
12071221 )
You can’t perform that action at this time.
0 commit comments