New submission from STINNER Victor: Lib/subprocess.py contains the following code:
try: exception_name, hex_errno, err_msg = ( errpipe_data.split(b':', 2)) except ValueError: exception_name = b'SubprocessError' hex_errno = b'0' err_msg = (b'Bad exception data from child: ' + repr(errpipe_data)) b'...' + repr() is wrong: it raises a "TypeError: can't concat str to bytes" when python3 is run with -bb. Example with attached subprocess_bug.patch: haypo@selma$ ./python -bb -m test -v test_subprocess -m test_invalid_args (...) ====================================================================== ERROR: test_invalid_args (test.test_subprocess.ContextManagerTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/haypo/prog/python/master/Lib/subprocess.py", line 1309, in _execute_child errpipe_data.split(b':', 1)) ValueError: not enough values to unpack (expected 3, got 2) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/haypo/prog/python/master/Lib/test/test_subprocess.py", line 2880, in test_invalid_args stderr=subprocess.PIPE) as proc: File "/home/haypo/prog/python/master/Lib/subprocess.py", line 709, in __init__ restore_signals, start_new_session) File "/home/haypo/prog/python/master/Lib/subprocess.py", line 1314, in _execute_child repr(errpipe_data)) TypeError: can't concat str to bytes IMHO err_msg should be decoded using err_msg.decode(errors="surrogatepass") and then use 'Bad ...: %s' % err_msg. It would need to add an "else:" block to the try/except to do the err_msg.decode(errors="surrogatepass") when no error is raised. Well, something like that :-) ---------- components: Library (Lib) files: subprocess_bug.patch keywords: easy, patch messages: 300102 nosy: haypo priority: normal severity: normal status: open title: [EASY] subprocess: TypeError: can't concat str to bytes, in _execute_child() versions: Python 3.7 Added file: http://bugs.python.org/file47077/subprocess_bug.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue31178> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com