mirror of
https://git.yoctoproject.org/poky
synced 2026-09-13 09:49:32 +02:00
devtool: fix handling of unicode characters from subprocess stdout
In previous implementation, a UnicodeDecodeError exception will be
raised if multi-byte encoded characters are printed by the subprocess.
As an example, the following command will fail in an en_US.UTF-8
environment because wget quotes its saving destination with '‘'(0xE2
0x80 0x98), while just the first byte is provided for decoding:
devtool add recipe http://example.com/source.tar.xz
The patch fixes the issue by avoiding such kind of incomplete decoding.
(From OE-Core rev: 1875ea92546d23abcab1b40b562477a0016f712d)
Signed-off-by: Jiajie Hu <jiajie.hu@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
8c84830fa1
commit
bfd8c35c3f
@@ -23,6 +23,7 @@ import sys
|
|||||||
import subprocess
|
import subprocess
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
import codecs
|
||||||
|
|
||||||
logger = logging.getLogger('devtool')
|
logger = logging.getLogger('devtool')
|
||||||
|
|
||||||
@@ -67,10 +68,10 @@ def exec_watch(cmd, **options):
|
|||||||
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **options
|
cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **options
|
||||||
)
|
)
|
||||||
|
|
||||||
|
reader = codecs.getreader('utf-8')(process.stdout)
|
||||||
buf = ''
|
buf = ''
|
||||||
while True:
|
while True:
|
||||||
out = process.stdout.read(1)
|
out = reader.read(1, 1)
|
||||||
out = out.decode('utf-8')
|
|
||||||
if out:
|
if out:
|
||||||
sys.stdout.write(out)
|
sys.stdout.write(out)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|||||||
Reference in New Issue
Block a user