mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-31961: subprocess now accepts path-like args (GH-4329)
Allow os.PathLike args in subprocess APIs.
This commit is contained in:
parent
14e976e00e
commit
dd42cb71f2
4 changed files with 55 additions and 8 deletions
|
@ -1097,7 +1097,12 @@ class Popen(object):
|
|||
assert not pass_fds, "pass_fds not supported on Windows."
|
||||
|
||||
if not isinstance(args, str):
|
||||
args = list2cmdline(args)
|
||||
try:
|
||||
args = os.fsdecode(args) # os.PathLike -> str
|
||||
except TypeError: # not an os.PathLike, must be a sequence.
|
||||
args = list(args)
|
||||
args[0] = os.fsdecode(args[0]) # os.PathLike -> str
|
||||
args = list2cmdline(args)
|
||||
|
||||
# Process startup details
|
||||
if startupinfo is None:
|
||||
|
@ -1369,7 +1374,10 @@ class Popen(object):
|
|||
if isinstance(args, (str, bytes)):
|
||||
args = [args]
|
||||
else:
|
||||
args = list(args)
|
||||
try:
|
||||
args = list(args)
|
||||
except TypeError: # os.PathLike instead of a sequence?
|
||||
args = [os.fsencode(args)] # os.PathLike -> [str]
|
||||
|
||||
if shell:
|
||||
# On Android the default shell is at '/system/bin/sh'.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue