From: Cleber Rosa <crosa@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: armbru@redhat.com, qemu-devel@nongnu.org, ehabkost@redhat.com
Subject: Re: [Qemu-devel] [PATCH] qmp: make qmp-shell work with python3
Date: Wed, 19 Jun 2019 09:29:24 -0400 [thread overview]
Message-ID: <20190619132924.GA32240@localhost.localdomain> (raw)
In-Reply-To: <20190618142931.1694-1-imammedo@redhat.com>
On Tue, Jun 18, 2019 at 10:29:31AM -0400, Igor Mammedov wrote:
> python3 doesn't have raw_input(), so qmp-shell breaks.
> Use input() instead and override it with raw_input()
> if running on python2.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> scripts/qmp/qmp-shell | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/qmp/qmp-shell b/scripts/qmp/qmp-shell
> index 7776c7b141..8c49b39afa 100755
> --- a/scripts/qmp/qmp-shell
> +++ b/scripts/qmp/qmp-shell
> @@ -308,7 +308,11 @@ class QMPShell(qmp.QEMUMonitorProtocol):
> @return True if execution was ok, return False if disconnected.
> """
> try:
> - cmdline = raw_input(prompt)
> + try: # attempt to set Python2 override
> + import __builtin__;
> + getattr(__builtin__, 'raw_input', input)
> + except ModuleNotFoundError: pass
Something like:
if sys.version_info[0] == 2:
input = raw_input
Also does the job, and may be considered simpler and easier to read.
- Cleber.
> + cmdline = input(prompt)
> except EOFError:
> print()
> return False
> --
> 2.18.1
>
next prev parent reply other threads:[~2019-06-19 13:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-18 14:29 [Qemu-devel] [PATCH] qmp: make qmp-shell work with python3 Igor Mammedov
2019-06-19 13:29 ` Cleber Rosa [this message]
2019-06-20 9:11 ` Igor Mammedov
2019-06-20 13:45 ` Eduardo Habkost
2019-06-20 15:16 ` Igor Mammedov
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=20190619132924.GA32240@localhost.localdomain \
--to=crosa@redhat.com \
--cc=armbru@redhat.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=qemu-devel@nongnu.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 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.