From: Daniele Buono <dbuono@linux.vnet.ibm.com>
To: "Philippe Mathieu-Daudé" <f4bug@amsat.org>, qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>,
Eduardo Habkost <ehabkost@redhat.com>,
Cleber Rosa <crosa@redhat.com>
Subject: Re: [PATCH] decodetree: Open files with encoding='utf-8'
Date: Fri, 8 Jan 2021 17:51:41 -0500 [thread overview]
Message-ID: <2cde5504-9df6-93fb-a014-daee2b907fde@linux.vnet.ibm.com> (raw)
In-Reply-To: <20210108151632.277015-1-f4bug@amsat.org>
I had a similar issue in the past with the acceptance tests.
Some VMs send UTF-8 output in their console and the acceptance test
script would bail out if the locale was not UTF-8.
I sent a patch on the ml but it probably got lost:
https://lists.gnu.org/archive/html/qemu-devel/2020-07/msg06086.html
I can re-spin it if you guys are interested
On 1/8/2021 10:16 AM, Philippe Mathieu-Daudé wrote:
> When decodetree.py was added in commit 568ae7efae7, QEMU was
> using Python 2 which happily reads UTF-8 files in text mode.
> Python 3 requires either UTF-8 locale or an explicit encoding
> passed to open(). Now that Python 3 is required, explicit
> UTF-8 encoding for decodetree sources.
>
> This fixes:
>
> $ /usr/bin/python3 scripts/decodetree.py test.decode
> Traceback (most recent call last):
> File "scripts/decodetree.py", line 1397, in <module>
> main()
> File "scripts/decodetree.py", line 1308, in main
> parse_file(f, toppat)
> File "scripts/decodetree.py", line 994, in parse_file
> for line in f:
> File "/usr/lib/python3.6/encodings/ascii.py", line 26, in decode
> return codecs.ascii_decode(input, self.errors)[0]
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 80:
> ordinal not in range(128)
>
> Reported-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> scripts/decodetree.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/decodetree.py b/scripts/decodetree.py
> index 47aa9caf6d1..fa40903cff1 100644
> --- a/scripts/decodetree.py
> +++ b/scripts/decodetree.py
> @@ -1304,7 +1304,7 @@ def main():
>
> for filename in args:
> input_file = filename
> - f = open(filename, 'r')
> + f = open(filename, 'r', encoding='utf-8')
> parse_file(f, toppat)
> f.close()
>
next prev parent reply other threads:[~2021-01-08 22:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-08 15:16 [PATCH] decodetree: Open files with encoding='utf-8' Philippe Mathieu-Daudé
2021-01-08 15:25 ` 罗勇刚(Yonggang Luo)
2021-01-08 15:38 ` Peter Maydell
2021-01-08 16:13 ` 罗勇刚(Yonggang Luo)
2021-01-08 16:43 ` Eduardo Habkost
2021-01-08 16:44 ` Philippe Mathieu-Daudé
2021-01-08 17:14 ` Peter Maydell
2021-01-08 18:02 ` Philippe Mathieu-Daudé
2021-01-08 22:51 ` Daniele Buono [this message]
2021-01-12 21:11 ` Eduardo Habkost
2021-01-12 23:35 ` John Snow
2021-01-12 23:44 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2cde5504-9df6-93fb-a014-daee2b907fde@linux.vnet.ibm.com \
--to=dbuono@linux.vnet.ibm.com \
--cc=crosa@redhat.com \
--cc=ehabkost@redhat.com \
--cc=f4bug@amsat.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).