[issue9922] subprocess.getstatusoutput can fail with utf8 UnicodeDecodeError
Ned Deily
report at bugs.python.org
Thu Sep 23 12:19:43 CEST 2010
Ned Deily <nad at acm.org> added the comment:
In Python 3, subprocess.Popen returns stdout as "bytes" rather than "string" so it seems reasonable that subprocess.getstatusoutput should do the same.
>>> subprocess.Popen(['dd if=/dev/random bs=1024 count=1'], shell=True, stdout=subprocess.PIPE).communicate()[0]
1+0 records in
1+0 records out
1024 bytes transferred in 0.000142 secs (7218432 bytes/sec)
b'\x11\xfb\xe1w ...
The problem is reproducible on 3.1 and py3k.
The attached patch for py3k (with a backport to 3.1) corrects getstatusoutput to return bytes. It also includes a test case and updates the docs to show byte output.
----------
keywords: +patch
nosy: +astrand, ned.deily
stage: -> patch review
title: subprocess.getstatusoutput and bytes -> subprocess.getstatusoutput can fail with utf8 UnicodeDecodeError
versions: +Python 3.1
Added file: http://bugs.python.org/file18971/issue9922-py3k.patch
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9922>
_______________________________________
More information about the Python-bugs-list
mailing list