GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Revert "bpo-31961: subprocess now accepts path-like args (GH-4329)" by serhiy-storchaka · Pull Request #5912 · python/cpython

Revert "bpo-31961: subprocess now accepts path-like args (GH-4329)" #5912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
ned-deily merged 2 commits into python:master from serhiy-storchaka:revert-31961
Feb 27, 2018

Uh oh!

There was an error while loading. Please reload this page.

Merged

Revert "bpo-31961: subprocess now accepts path-like args (GH-4329)" #5912

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
2 commits
Select commit Hold shift + click to select a range
ef212f0
Revert "bpo-31961: subprocess now accepts path-like args (GH-4329)"
serhiy-storchaka Feb 26, 2018
d13d0a5
Update the NEWS entry.
serhiy-storchaka Feb 26, 2018
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

16 changes: 6 additions & 10 deletions 16 Doc/library/subprocess.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -339,12 +339,12 @@ functions.
the class uses the Windows ``CreateProcess()`` function. The arguments to
:class:`Popen` are as follows.

*args* should be a sequence of program arguments or else a single string or
:term:`path-like object`. By default, the program to execute is the first
item in *args* if *args* is a sequence. If *args* is a string, the
interpretation is platform-dependent and described below. See the *shell*
and *executable* arguments for additional differences from the default
behavior. Unless otherwise stated, it is recommended to pass *args* as a sequence.
*args* should be a sequence of program arguments or else a single string.
By default, the program to execute is the first item in *args* if *args* is
a sequence. If *args* is a string, the interpretation is
platform-dependent and described below. See the *shell* and *executable*
arguments for additional differences from the default behavior. Unless
otherwise stated, it is recommended to pass *args* as a sequence.

On POSIX, if *args* is a string, the string is interpreted as the name or
path of the program to execute. However, this can only be done if not
Expand Down Expand Up @@ -558,10 +558,6 @@ functions.
Popen destructor now emits a :exc:`ResourceWarning` warning if the child
process is still running.

.. versionchanged:: 3.7
*args*, or the first element of *args* if *args* is a sequence, can now
be a :term:`path-like object`.


Exceptions
^^^^^^^^^^
Expand Down
12 changes: 2 additions & 10 deletions 12 Lib/subprocess.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1097,12 +1097,7 @@ def _execute_child(self, args, executable, preexec_fn, close_fds,
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:
Expand Down Expand Up @@ -1374,10 +1369,7 @@ def _execute_child(self, args, executable, preexec_fn, close_fds,
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'.
Expand Down
31 changes: 0 additions & 31 deletions 31 Lib/test/test_subprocess.py
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -1475,37 +1475,6 @@ def test_run_kwargs(self):
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'); "
Expand Down
1 change: 1 addition & 0 deletions 1 Misc/NEWS.d/3.7.0b1.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ Add contextlib.AsyncExitStack. Patch by Alexander Mohr and Ilya Kulakov.
.. nonce: x5Sv0R
.. section: Library

*Removed in Python 3.7.0b2.*
The *args* argument of subprocess.Popen can now be a :term:`path-like
object`. If *args* is given as a sequence, it's first element can now be a
:term:`path-like object` as well.
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.