@@ -304,7 +304,7 @@ def kill(self) -> None:
304
304
305
305
306
306
async def _open_process (
307
- command : list [ str ] | str ,
307
+ command : StrOrBytesPath | Sequence [ StrOrBytesPath ] ,
308
308
* ,
309
309
stdin : int | HasFileno | None = None ,
310
310
stdout : int | HasFileno | None = None ,
@@ -329,13 +329,14 @@ async def _open_process(
329
329
want.
330
330
331
331
Args:
332
- command (list or str): The command to run. Typically this is a
333
- sequence of strings such as ``['ls', '-l', 'directory with spaces']``,
334
- where the first element names the executable to invoke and the other
335
- elements specify its arguments. With ``shell=True`` in the
336
- ``**options``, or on Windows, ``command`` may alternatively
337
- be a string, which will be parsed following platform-dependent
338
- :ref:`quoting rules <subprocess-quoting>`.
332
+ command: The command to run. Typically this is a sequence of strings or
333
+ bytes such as ``['ls', '-l', 'directory with spaces']``, where the
334
+ first element names the executable to invoke and the other elements
335
+ specify its arguments. With ``shell=True`` in the ``**options``, or on
336
+ Windows, ``command`` can be a string or bytes, which will be parsed
337
+ following platform-dependent :ref:`quoting rules
338
+ <subprocess-quoting>`. In all cases ``command`` can be a path or a
339
+ sequence of paths.
339
340
stdin: Specifies what the child process's standard input
340
341
stream should connect to: output written by the parent
341
342
(``subprocess.PIPE``), nothing (``subprocess.DEVNULL``),
@@ -369,15 +370,16 @@ async def _open_process(
369
370
)
370
371
371
372
if os .name == "posix" :
372
- if isinstance (command , str ) and not options .get ("shell" ):
373
+ # TODO: how do paths and sequences thereof play with `shell=True`?
374
+ if isinstance (command , (str , bytes )) and not options .get ("shell" ):
373
375
raise TypeError (
374
- "command must be a sequence (not a string) if shell=False "
375
- "on UNIX systems" ,
376
+ "command must be a sequence (not a string or bytes ) if "
377
+ "shell=False on UNIX systems" ,
376
378
)
377
- if not isinstance (command , str ) and options .get ("shell" ):
379
+ if not isinstance (command , ( str , bytes ) ) and options .get ("shell" ):
378
380
raise TypeError (
379
- "command must be a string (not a sequence) if shell=True "
380
- "on UNIX systems" ,
381
+ "command must be a string or bytes (not a sequence) if "
382
+ "shell=True on UNIX systems" ,
381
383
)
382
384
383
385
trio_stdin : ClosableSendStream | None = None
0 commit comments