From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Cc: crosa@redhat.com, jsnow@redhat.com, mdroth@linux.vnet.ibm.com,
ehabkost@redhat.com
Subject: Re: [PATCH 2/4] qapi: Drop conditionals for Python 2
Date: Thu, 27 Feb 2020 16:29:30 +0100 [thread overview]
Message-ID: <fb8fe3bf-da1f-2c6b-933c-c8a79bdee9fa@redhat.com> (raw)
In-Reply-To: <20200227144531.24309-3-armbru@redhat.com>
On 2/27/20 3:45 PM, Markus Armbruster wrote:
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
> scripts/qapi/common.py | 6 +-----
> scripts/qapi/gen.py | 6 +-----
> scripts/qapi/parser.py | 6 +-----
> tests/qapi-schema/test-qapi.py | 6 +-----
> 4 files changed, 4 insertions(+), 20 deletions(-)
>
> diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py
> index e00dcafce7..ba35abea47 100644
> --- a/scripts/qapi/common.py
> +++ b/scripts/qapi/common.py
> @@ -12,7 +12,6 @@
> # See the COPYING file in the top-level directory.
>
> import re
> -import string
>
>
> # ENUMName -> ENUM_NAME, EnumName1 -> ENUM_NAME1
> @@ -43,10 +42,7 @@ def c_enum_const(type_name, const_name, prefix=None):
> return camel_to_upper(type_name) + '_' + c_name(const_name, False).upper()
>
>
> -if hasattr(str, 'maketrans'):
> - c_name_trans = str.maketrans('.-', '__')
> -else:
> - c_name_trans = string.maketrans('.-', '__')
> +c_name_trans = str.maketrans('.-', '__')
>
>
> # Map @name to a valid C identifier.
> diff --git a/scripts/qapi/gen.py b/scripts/qapi/gen.py
> index a53a705c73..317cd72601 100644
> --- a/scripts/qapi/gen.py
> +++ b/scripts/qapi/gen.py
> @@ -15,7 +15,6 @@
> import errno
> import os
> import re
> -import sys
> from contextlib import contextmanager
>
> from qapi.common import *
> @@ -54,10 +53,7 @@ class QAPIGen:
> if e.errno != errno.EEXIST:
> raise
> fd = os.open(pathname, os.O_RDWR | os.O_CREAT, 0o666)
> - if sys.version_info[0] >= 3:
> - f = open(fd, 'r+', encoding='utf-8')
> - else:
> - f = os.fdopen(fd, 'r+')
> + f = open(fd, 'r+', encoding='utf-8')
> text = self.get_content()
> oldtext = f.read(len(text) + 1)
> if text != oldtext:
> diff --git a/scripts/qapi/parser.py b/scripts/qapi/parser.py
> index 2e3a3c5d76..cf14e5426c 100644
> --- a/scripts/qapi/parser.py
> +++ b/scripts/qapi/parser.py
> @@ -16,7 +16,6 @@
>
> import os
> import re
> -import sys
> from collections import OrderedDict
>
> from qapi.error import QAPIParseError, QAPISemError
> @@ -30,10 +29,7 @@ class QAPISchemaParser:
> previously_included.add(os.path.abspath(fname))
>
> try:
> - if sys.version_info[0] >= 3:
> - fp = open(fname, 'r', encoding='utf-8')
> - else:
> - fp = open(fname, 'r')
> + fp = open(fname, 'r', encoding='utf-8')
> self.src = fp.read()
> except IOError as e:
> raise QAPISemError(incl_info or QAPISourceInfo(None, None, None),
> diff --git a/tests/qapi-schema/test-qapi.py b/tests/qapi-schema/test-qapi.py
> index 41232c11a3..bee18ee344 100755
> --- a/tests/qapi-schema/test-qapi.py
> +++ b/tests/qapi-schema/test-qapi.py
> @@ -16,15 +16,11 @@ import argparse
> import difflib
> import os
> import sys
> +from io import StringIO
>
> from qapi.error import QAPIError
> from qapi.schema import QAPISchema, QAPISchemaVisitor
>
> -if sys.version_info[0] < 3:
> - from cStringIO import StringIO
> -else:
> - from io import StringIO
> -
>
> class QAPISchemaTestVisitor(QAPISchemaVisitor):
>
>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
next prev parent reply other threads:[~2020-02-27 15:30 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-27 14:45 [PATCH 0/4] qapi: Bye-bye Python 2 Markus Armbruster
2020-02-27 14:45 ` [PATCH 1/4] qapi: Inheriting from object is pointless with Python 3, drop Markus Armbruster
2020-02-27 15:30 ` Philippe Mathieu-Daudé
2020-02-27 14:45 ` [PATCH 2/4] qapi: Drop conditionals for Python 2 Markus Armbruster
2020-02-27 15:29 ` Philippe Mathieu-Daudé [this message]
2020-02-27 14:45 ` [PATCH 3/4] qapi: Use super() now we have Python 3 Markus Armbruster
2020-03-04 7:32 ` Markus Armbruster
2020-02-27 14:45 ` [PATCH 4/4] qapi: Brush off some (py)lint Markus Armbruster
2020-03-03 22:03 ` John Snow
2020-03-04 8:01 ` Markus Armbruster
2020-03-04 19:27 ` John Snow
2020-03-05 5:42 ` Markus Armbruster
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=fb8fe3bf-da1f-2c6b-933c-c8a79bdee9fa@redhat.com \
--to=philmd@redhat.com \
--cc=armbru@redhat.com \
--cc=crosa@redhat.com \
--cc=ehabkost@redhat.com \
--cc=jsnow@redhat.com \
--cc=mdroth@linux.vnet.ibm.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.