From: Kamalesh Babulal Date: Wed, 23 Feb 2022 13:43:33 +0000 (+0530) Subject: run.py: fix codec type used to decode stdout, stderr X-Git-Tag: v3.1.0~308^2~2^2~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d9bc84f4a71b6915c570b18b19ce04f6cc6b94d5;p=thirdparty%2Flibcgroup.git run.py: fix codec type used to decode stdout, stderr Codec 'ascii' only decodes English and can't understand other characters and raise an UnicodeDecodeError. For example, consider running 'mkdir' on an already existing directory, it would trigger: err.strip().decode('ascii') Traceback (most recent call last): File "", line 1, in UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 31: ordinal not in range(128) fix it by using 'UTF-8' as Codec for decoding, with the patch stderr will be: err.strip().decode('UTF-8') 'mkdir: cannot create directory ‘out’: File exists' Signed-off-by: Kamalesh Babulal Signed-off-by: Tom Hromatka --- diff --git a/ftests/run.py b/ftests/run.py index ef837083..1144986a 100644 --- a/ftests/run.py +++ b/ftests/run.py @@ -41,8 +41,8 @@ class Run(object): out, err = subproc.communicate() ret = subproc.returncode - out = out.strip().decode('ascii') - err = err.strip().decode('ascii') + out = out.strip().decode('UTF-8') + err = err.strip().decode('UTF-8') if shell_bool: Log.log_debug(