summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2018-02-27 23:03:46 (GMT)
committerNed Deily <nad@python.org>2018-02-27 23:03:46 (GMT)
commitbe50a7b627d0aa37e08fa8e2d5568891f19903ce (patch)
treed8a26b4e730f826289ec05d0620bb2e7fbaa3095 /Lib
parentcc5ac04c07097218477064a38d551f62fe682447 (diff)
downloadcpython-be50a7b627d0aa37e08fa8e2d5568891f19903ce.zip
cpython-be50a7b627d0aa37e08fa8e2d5568891f19903ce.tar.gz
cpython-be50a7b627d0aa37e08fa8e2d5568891f19903ce.tar.bz2
Revert "bpo-31961: subprocess now accepts path-like args (GH-4329)" (#5912)
* Revert "bpo-31961: subprocess now accepts path-like args (GH-4329)" This reverts commit dd42cb71f2cb02f3a32f016137b12a146bc0d0e2.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/subprocess.py12
-rw-r--r--Lib/test/test_subprocess.py31
2 files changed, 2 insertions, 41 deletions
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 2723bc9..93635ee 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -1097,12 +1097,7 @@ class Popen(object):
assert not pass_fds, "pass_fds not supported on Windows."
if not isinstance(args, str):
- 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)
+ args = list2cmdline(args)
# Process startup details
if startupinfo is None:
@@ -1374,10 +1369,7 @@ class Popen(object):
if isinstance(args, (str, bytes)):
args = [args]
else:
- try:
- args = list(args)
- except TypeError: # os.PathLike instead of a sequence?
- args = [os.fsencode(args)] # os.PathLike -> [str]
+ args = list(args)
if shell:
# On Android the default shell is at '/system/bin/sh'.
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index b3ccb0d..46cb5f1 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -1475,37 +1475,6 @@ class RunFuncTestCase(BaseTestCase):
env=newenv)
self.assertEqual(cp.returncode, 33)
- def test_run_with_pathlike_path(self):
- # bpo-31961: test run(pathlike_object)
- class Path:
- def __fspath__(self):
- # the name of a command that can be run without
- # any argumenets that exit fast
- return 'dir' if mswindows else 'ls'
-
- path = Path()
- if mswindows:
- res = subprocess.run(path, stdout=subprocess.DEVNULL, shell=True)
- else:
- res = subprocess.run(path, stdout=subprocess.DEVNULL)
-
- self.assertEqual(res.returncode, 0)
-
- def test_run_with_pathlike_path_and_arguments(self):
- # bpo-31961: test run([pathlike_object, 'additional arguments'])
- class Path:
- def __fspath__(self):
- # the name of a command that can be run without
- # any argumenets that exits fast
- return sys.executable
-
- path = Path()
-
- args = [path, '-c', 'import sys; sys.exit(57)']
- res = subprocess.run(args)
-
- self.assertEqual(res.returncode, 57)
-
def test_capture_output(self):
cp = self.run_python(("import sys;"
"sys.stdout.write('BDFL'); "