qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eduardo Habkost <ehabkost@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org, "Fam Zheng" <famz@redhat.com>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Stefan Hajnoczi" <stefanha@redhat.com>,
	"Cleber Rosa" <crosa@redhat.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Markus Armbruster" <armbru@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 6/6] docker: Open dockerfiles in text mode
Date: Wed, 27 Jun 2018 10:34:49 -0300	[thread overview]
Message-ID: <20180627133449.GW7451@localhost.localdomain> (raw)
In-Reply-To: <6c6da5dd-0ab4-b4c4-9411-169f9dfbbdfc@redhat.com>

On Wed, Jun 27, 2018 at 07:51:01AM -0500, Eric Blake wrote:
> On 06/26/2018 09:14 PM, Eduardo Habkost wrote:
> > Instead of treating dockerfile contents as byte sequences, always
> > open dockerfiles in text mode and treat it as text.
> > 
> > This is not strictly required to make the script compatible with
> > Python 3, but it's a simpler and safer way than opening
> > dockerfiles in binary mode and decoding the data data later.
> 
> s/data data/data/

Thanks.

> 
> > 
> > To make the code compatible with both Python 2 and 3, use
> > io.open(), which accepts a 'encoding' argument on both versions.
> 
> How does this compare to the recent change to the QAPI generators in commit
> de685ae5e?  Should we be trying to use similar mechanisms in both places?

We could do the same and use io.open(..., encoding='utf-8')
unconditionally on QAPI too, but it may be harder because of its
usage of insinstance() and the 'str' type[1] everywhere.

One solution I considered on QAPI was using
'__future__.unicode_literals' and the 'builtins.str' type from
python-future, but I don't think QAPI's specific case justify
adding a new build dependency on Python 2.7 hosts.

Adding type annotations to the QAPI code may help us sort out the
mess more easily.

[1] 'str' on Python 2.7 is more similar to the 'bytes' type on
    Python 3, but io.open(..., encoding=...) on Python 2.7
    returns 'unicode' objects (that that are more similar to the
    native 'str' type from Python 3).

-- 
Eduardo

      reply	other threads:[~2018-06-27 13:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-27  2:14 [Qemu-devel] [PATCH 0/6] docker: Port to Python 3 Eduardo Habkost
2018-06-27  2:14 ` [Qemu-devel] [PATCH 1/6] docker: Use BytesIO instead of StringIO Eduardo Habkost
2018-06-27  2:14 ` [Qemu-devel] [PATCH 2/6] docker: Always return int on run() Eduardo Habkost
2018-06-27  2:14 ` [Qemu-devel] [PATCH 3/6] docker: Add type annotations Eduardo Habkost
2018-06-27  2:14 ` [Qemu-devel] [PATCH 4/6] docker: Use os.environ.items() instead of .iteritems() Eduardo Habkost
2018-06-27  2:22   ` Philippe Mathieu-Daudé
2018-06-27  2:14 ` [Qemu-devel] [PATCH 5/6] docker: Make _get_so_libs() work on Python 3 Eduardo Habkost
2018-06-27  2:14 ` [Qemu-devel] [PATCH 6/6] docker: Open dockerfiles in text mode Eduardo Habkost
2018-06-27 12:51   ` Eric Blake
2018-06-27 13:34     ` Eduardo Habkost [this message]

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=20180627133449.GW7451@localhost.localdomain \
    --to=ehabkost@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=armbru@redhat.com \
    --cc=crosa@redhat.com \
    --cc=eblake@redhat.com \
    --cc=f4bug@amsat.org \
    --cc=famz@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@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 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).