add encoding parameter for subprocess.check_output() function in Python 3.6+ (#1095)

* add encoding parameter for check_output() function in Python 3.6+

* add errors parameter for subprocess.check_output() function
This commit is contained in:
Shengpei Zhang
2017-03-25 14:07:25 -07:00
committed by Jelle Zijlstra
parent 16074c1e66
commit c0bbfbdec5

View File

@@ -46,8 +46,9 @@ if sys.version_info >= (3, 5):
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
encoding: str = ...,
errors: str = ...) -> CompletedProcess: ...
*,
encoding: Optional[str] = ...,
errors: Optional[str] = ...) -> CompletedProcess: ...
else:
# Nearly same args as Popen.__init__ except for timeout, input, and check
def run(args: _CMD,
@@ -151,7 +152,31 @@ else:
start_new_session: bool = ...,
pass_fds: Any = ...) -> int: ...
if sys.version_info >= (3, 4):
if sys.version_info >= (3, 6):
# 3.6 added encoding and errors
def check_output(args: _CMD,
bufsize: int = ...,
executable: _TXT = ...,
stdin: _FILE = ...,
stderr: _FILE = ...,
preexec_fn: Callable[[], Any] = ...,
close_fds: bool = ...,
shell: bool = ...,
cwd: _TXT = ...,
env: _ENV = ...,
universal_newlines: bool = ...,
startupinfo: Any = ...,
creationflags: int = ...,
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
*,
timeout: float = ...,
input: _TXT = ...,
encoding: Optional[str] = ...,
errors: Optional[str] = ...,
) -> Any: ... # morally: -> _TXT
elif sys.version_info >= (3, 4):
# 3.4 added input
def check_output(args: _CMD,
bufsize: int = ...,
@@ -266,8 +291,9 @@ class Popen:
restore_signals: bool = ...,
start_new_session: bool = ...,
pass_fds: Any = ...,
encoding: str = ...,
errors: str = ...) -> None: ...
*,
encoding: Optional[str] = ...,
errors: Optional[str] = ...) -> None: ...
else:
def __init__(self,
args: _CMD,