Skip to content

Commit

Permalink
subprocess.check_call: executable defaults to None (#9689)
Browse files Browse the repository at this point in the history
This argument is forwarded on to `Popen.__init__`, like most of the other arguments. It can be `None`, just like the `executable` parameter for all the other `subprocess` functions:

```pycon
>>> import subprocess
>>> subprocess.check_call(["python", "-c", "1/1"], executable=None)
0
>>> subprocess.check_call(["python", "-c", "1/0"], executable=None)
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ZeroDivisionError: division by zero
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\alexw\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 369, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['python', '-c', '1/0']' returned non-zero exit status 1.
```
  • Loading branch information
AlexWaygood authored Feb 7, 2023
1 parent 53747b2 commit 32c575d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions stdlib/subprocess.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ if sys.version_info >= (3, 11):
def check_call(
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath = ...,
executable: StrOrBytesPath | None = None,
stdin: _FILE = ...,
stdout: _FILE = ...,
stderr: _FILE = ...,
Expand Down Expand Up @@ -1025,7 +1025,7 @@ elif sys.version_info >= (3, 10):
def check_call(
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath = ...,
executable: StrOrBytesPath | None = None,
stdin: _FILE = ...,
stdout: _FILE = ...,
stderr: _FILE = ...,
Expand Down Expand Up @@ -1055,7 +1055,7 @@ elif sys.version_info >= (3, 9):
def check_call(
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath = ...,
executable: StrOrBytesPath | None = None,
stdin: _FILE = ...,
stdout: _FILE = ...,
stderr: _FILE = ...,
Expand Down Expand Up @@ -1083,7 +1083,7 @@ else:
def check_call(
args: _CMD,
bufsize: int = ...,
executable: StrOrBytesPath = ...,
executable: StrOrBytesPath | None = None,
stdin: _FILE = ...,
stdout: _FILE = ...,
stderr: _FILE = ...,
Expand Down

0 comments on commit 32c575d

Please sign in to comment.