[issue43431] Subprocess timeout causes output to be returned as bytes in text mode

2021-03-08 Thread Jordan Macdonald


Jordan Macdonald  added the comment:

Eryk Sun: Well, I think step 1 should be to update the documentation for Python 
3.7 through 3.10 on `subprocess.run()` and `subprocess.TimeoutExpired` to 
clearly state that `TimeoutExpired.stdout` and `TimeoutExpired.stderr` will be 
in bytes format even if text mode is set.

If we went with the model of having `stdout_bytes` and attempting to decode 
into `stdout`, we'd want an option to ignore a trailing decoding error.

--
versions: +Python 3.7

___
Python tracker 
<https://bugs.python.org/issue43431>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue43431] Subprocess timeout causes output to be returned as bytes in text mode

2021-03-07 Thread Jordan Macdonald


New submission from Jordan Macdonald :

Passing the argument `text=True` to `subprocess.run()` is supposed to mean that 
any captured output of the called process is automatically decoded and retuned 
to the user as test instead of bytes.

However, if you give a timeout and that timeout expires, the raised 
`subprocess.TimeoutExpired` exception will have the captured output as as bytes 
even if text mode is enabled.

Test output:
bash-5.0$ python3 test_subprocess.py
Version and interpreter information: namespace(_multiarch='x86_64-linux-gnu', 
cache_tag='cpython-37', hexversion=50792432, name='cpython', 
version=sys.version_info(major=3, minor=7, micro=7, releaselevel='final', 
serial=0))
Completed STDOUT Type: 
Completed STDOUT Content: 'Start\nDone\n'
Timeout STDOUT Type: 
Timeout STDOUT Content: b'Start\n'

--
components: Library (Lib)
files: test_subprocess.py
messages: 388257
nosy: macdjord
priority: normal
severity: normal
status: open
title: Subprocess timeout causes output to be returned as bytes in text mode
type: behavior
versions: Python 3.7
Added file: https://bugs.python.org/file49856/test_subprocess.py

___
Python tracker 
<https://bugs.python.org/issue43431>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com