Author haypo
Recipients haypo
Date 2017-08-10.15:29:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1502378984.02.0.493180637871.issue31178@psf.upfronthosting.co.za>
In-reply-to
Content
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 :-)
History
Date User Action Args
2017-08-10 15:29:44hayposetrecipients: + haypo
2017-08-10 15:29:44hayposetmessageid: <1502378984.02.0.493180637871.issue31178@psf.upfronthosting.co.za>
2017-08-10 15:29:43haypolinkissue31178 messages
2017-08-10 15:29:43haypocreate