Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Lib/subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ def list2cmdline(seq):
result = []
needquote = False
for arg in seq:
arg = os.fspath(arg)
bs_buf = []

# Add a space to separate this argument from the others
Expand Down
14 changes: 14 additions & 0 deletions Lib/test/test_subprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import threading
import gc
import textwrap
import pathlib
from test.support import FakePath

try:
Expand Down Expand Up @@ -118,6 +119,19 @@ def test_io_unbuffered_works(self):
p.stderr.close()
p.wait()

def test_pathlib_executable(self):
p = subprocess.Popen([pathlib.Path(sys.executable), "-c",
"import sys; sys.exit(47)"])
p.wait()
self.assertEqual(p.returncode, 47)

def test_pathlib_argument(self):
path = pathlib.Path(sys.executable)
output = subprocess.check_output([path, "-c",
"import sys; sys.stdout.write(sys.argv[1])",
path])
self.assertEqual(output, os.fspath(path).encode())

def test_call_seq(self):
# call() function with sequence argument
rc = subprocess.call([sys.executable, "-c",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use os.fspath() on elements of sequences passed to subprocess.Popen() on Windows.