From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>
Cc: "Thomas Huth" <thuth@redhat.com>,
qemu-devel@nongnu.org, "Michael Roth" <mdroth@linux.vnet.ibm.com>,
"Markus Armbruster" <armbru@redhat.com>,
"Cleber Rosa" <crosa@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: Re: [Qemu-devel] [PATCH] tests: Force Python I/O encoding for check-qapi-schema
Date: Tue, 7 May 2019 15:13:45 +0100 [thread overview]
Message-ID: <20190507141345.GS27205@redhat.com> (raw)
In-Reply-To: <20190506213817.14344-1-ehabkost@redhat.com>
On Mon, May 06, 2019 at 06:38:17PM -0300, Eduardo Habkost wrote:
> test-qapi.py doesn't force a specific encoding for stderr or
> stdout, but the reference files used by check-qapi-schema are in
> UTF-8. This breaks check-qapi-schema under certain circumstances
> (e.g. if using the C locale and Python < 3.7).
>
> We need to make sure test-qapi.py always generate UTF-8 output
> somehow. On Python 3.7+ we can do it using
> `sys.stdout.reconfigure(...)`, but we need a solution that works
> with older Python versions.
>
> Instead of trying a hack like reopening sys.stdout and
> sys.stderr, we can just tell Python to use UTF-8 for I/O encoding
> when running test-qapi.py. Do it by setting PYTHONIOENCODING.
>
> Reported-by: Thomas Huth <thuth@redhat.com>
> Tested-by: Thomas Huth <thuth@redhat.com>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> tests/Makefile.include | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tests/Makefile.include b/tests/Makefile.include
> index 7c8b9c84b2..af88ab6f8b 100644
> --- a/tests/Makefile.include
> +++ b/tests/Makefile.include
> @@ -1103,7 +1103,7 @@ check-tests/qemu-iotests-quick.sh: tests/qemu-iotests-quick.sh qemu-img$(EXESUF)
> .PHONY: $(patsubst %, check-%, $(check-qapi-schema-y))
> $(patsubst %, check-%, $(check-qapi-schema-y)): check-%.json: $(SRC_PATH)/%.json
> $(call quiet-command, PYTHONPATH=$(SRC_PATH)/scripts \
> - $(PYTHON) $(SRC_PATH)/tests/qapi-schema/test-qapi.py \
> + PYTHONIOENCODING=utf-8 $(PYTHON) $(SRC_PATH)/tests/qapi-schema/test-qapi.py \
I see PYTHONIOENCODING exists since 2.6 which is nice.
How about we actually change $(PYTHON) so that it always includes
PYTHONIOENCODING=utf-8 ?
That way we avoid continuing to play whack-a-mole with more utf-8
bugs in future.
It would also let us revert this:
commit de685ae5e9a4b523513033bd6cadc8187a227170
Author: Markus Armbruster <armbru@redhat.com>
Date: Mon Jun 18 19:59:57 2018 +0200
qapi: Open files with encoding='utf-8'
which had to provide separate logic for py2 vs py3 :-(
Regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2019-05-07 14:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-06 21:38 [Qemu-devel] [PATCH] tests: Force Python I/O encoding for check-qapi-schema Eduardo Habkost
2019-05-07 5:21 ` Philippe Mathieu-Daudé
2019-05-07 14:13 ` Daniel P. Berrangé [this message]
2019-05-07 14:45 ` Eduardo Habkost
2019-05-08 13:04 ` Markus Armbruster
2019-05-08 17:53 ` Eduardo Habkost
2019-05-09 8:42 ` Markus Armbruster
2019-05-08 9:19 ` Alex Bennée
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=20190507141345.GS27205@redhat.com \
--to=berrange@redhat.com \
--cc=armbru@redhat.com \
--cc=crosa@redhat.com \
--cc=ehabkost@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=philmd@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.