From patchwork Thu Aug 31 14:24:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 808263 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xjl5g458wz9s83 for ; Fri, 1 Sep 2017 00:25:27 +1000 (AEST) Received: from localhost ([::1]:56041 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnQPN-0007t5-HT for incoming@patchwork.ozlabs.org; Thu, 31 Aug 2017 10:25:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43415) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnQOf-0007qj-C2 for qemu-devel@nongnu.org; Thu, 31 Aug 2017 10:24:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dnQOe-0007ad-Bq for qemu-devel@nongnu.org; Thu, 31 Aug 2017 10:24:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60434) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dnQOe-0007a7-37 for qemu-devel@nongnu.org; Thu, 31 Aug 2017 10:24:40 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1FC537E456; Thu, 31 Aug 2017 14:24:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 1FC537E456 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=berrange@redhat.com Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id D3AD27BAE3; Thu, 31 Aug 2017 14:24:35 +0000 (UTC) From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Thu, 31 Aug 2017 15:24:26 +0100 Message-Id: <20170831142430.16665-2-berrange@redhat.com> In-Reply-To: <20170831142430.16665-1-berrange@redhat.com> References: <20170831142430.16665-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 31 Aug 2017 14:24:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 1/5] qapi: convert to use python print function instead of statement X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , Michael Roth Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Get Py2 + 3 compatibility by using the print function instead of print statement. This works for 2.6 onwards. Signed-off-by: Daniel P. Berrange --- scripts/qapi.py | 12 ++++++------ scripts/qapi2texi.py | 9 +++++---- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index 8aa2775f12..a60b79c126 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -11,6 +11,7 @@ # This work is licensed under the terms of the GNU GPL, version 2. # See the COPYING file in the top-level directory. +from __future__ import print_function import errno import getopt import os @@ -1476,7 +1477,7 @@ class QAPISchema(object): self._def_exprs() self.check() except QAPIError as err: - print >>sys.stderr, err + print (err, file=sys.stderr) exit(1) def _def_entity(self, ent): @@ -1936,7 +1937,7 @@ def parse_command_line(extra_options='', extra_long_options=[]): ['source', 'header', 'prefix=', 'output-dir='] + extra_long_options) except getopt.GetoptError as err: - print >>sys.stderr, "%s: %s" % (sys.argv[0], str(err)) + print ("%s: %s" % (sys.argv[0], str(err)), file=sys.stderr) sys.exit(1) output_dir = '' @@ -1950,9 +1951,8 @@ def parse_command_line(extra_options='', extra_long_options=[]): if o in ('-p', '--prefix'): match = re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', a) if match.end() != len(a): - print >>sys.stderr, \ - "%s: 'funny character '%s' in argument of --prefix" \ - % (sys.argv[0], a[match.end()]) + print ("%s: 'funny character '%s' in argument of --prefix" \ + % (sys.argv[0], a[match.end()]), file=sys.stderr) sys.exit(1) prefix = a elif o in ('-o', '--output-dir'): @@ -1969,7 +1969,7 @@ def parse_command_line(extra_options='', extra_long_options=[]): do_h = True if len(args) != 1: - print >>sys.stderr, "%s: need exactly one argument" % sys.argv[0] + print ("%s: need exactly one argument" % sys.argv[0], file=sys.stderr) sys.exit(1) fname = args[0] diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py index a317526e51..9c57b01bb4 100755 --- a/scripts/qapi2texi.py +++ b/scripts/qapi2texi.py @@ -4,6 +4,7 @@ # This work is licensed under the terms of the GNU LGPL, version 2+. # See the COPYING file in the top-level directory. """This script produces the documentation of a qapi schema in texinfo format""" +from __future__ import print_function import re import sys @@ -285,15 +286,15 @@ def texi_schema(schema): def main(argv): """Takes schema argument, prints result to stdout""" if len(argv) != 2: - print >>sys.stderr, "%s: need exactly 1 argument: SCHEMA" % argv[0] + print ("%s: need exactly 1 argument: SCHEMA" % argv[0], file=sys.stderr) sys.exit(1) schema = qapi.QAPISchema(argv[1]) if not qapi.doc_required: - print >>sys.stderr, ("%s: need pragma 'doc-required' " - "to generate documentation" % argv[0]) + print ("%s: need pragma 'doc-required' " + "to generate documentation" % argv[0], file=sys.stderr) sys.exit(1) - print texi_schema(schema) + print (texi_schema(schema)) if __name__ == '__main__': From patchwork Thu Aug 31 14:24:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 808267 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xjl8j1GM8z9s83 for ; Fri, 1 Sep 2017 00:28:05 +1000 (AEST) Received: from localhost ([::1]:56054 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnQRv-00026s-5M for incoming@patchwork.ozlabs.org; Thu, 31 Aug 2017 10:28:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43441) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnQOi-0007tO-Mp for qemu-devel@nongnu.org; Thu, 31 Aug 2017 10:24:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dnQOh-0007bh-Hn for qemu-devel@nongnu.org; Thu, 31 Aug 2017 10:24:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42250) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dnQOh-0007bP-8h for qemu-devel@nongnu.org; Thu, 31 Aug 2017 10:24:43 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4B59D81DEE; Thu, 31 Aug 2017 14:24:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4B59D81DEE Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=berrange@redhat.com Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 696FA7BAE3; Thu, 31 Aug 2017 14:24:39 +0000 (UTC) From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Thu, 31 Aug 2017 15:24:27 +0100 Message-Id: <20170831142430.16665-3-berrange@redhat.com> In-Reply-To: <20170831142430.16665-1-berrange@redhat.com> References: <20170831142430.16665-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 31 Aug 2017 14:24:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 2/5] qapi: use items()/values() intead of iteritems()/itervalues() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , Michael Roth Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The iteritems()/itervalues() methods are gone in py3, but the items()/values() methods are still around. The latter are less efficient than the former in py2, but this has unmeasurably small impact on QEMU build time, so taking portability over efficiency is a net win Signed-off-by: Daniel P. Berrange --- scripts/qapi.py | 12 ++++++------ scripts/qapi2texi.py | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index a60b79c126..d89af7d6c6 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -253,7 +253,7 @@ class QAPIDoc(object): "'Returns:' is only valid for commands") def check(self): - bogus = [name for name, section in self.args.iteritems() + bogus = [name for name, section in self.args.items() if not section.member] if bogus: raise QAPISemError( @@ -309,7 +309,7 @@ class QAPISchemaParser(object): if not isinstance(pragma, dict): raise QAPISemError( info, "Value of 'pragma' must be a dictionary") - for name, value in pragma.iteritems(): + for name, value in pragma.items(): self._pragma(name, value, info) else: expr_elem = {'expr': expr, @@ -1575,7 +1575,7 @@ class QAPISchema(object): def _make_members(self, data, info): return [self._make_member(key, value, info) - for (key, value) in data.iteritems()] + for (key, value) in data.items()] def _def_struct_type(self, expr, info, doc): name = expr['struct'] @@ -1607,11 +1607,11 @@ class QAPISchema(object): name, info, doc, 'base', self._make_members(base, info))) if tag_name: variants = [self._make_variant(key, value) - for (key, value) in data.iteritems()] + for (key, value) in data.items()] members = [] else: variants = [self._make_simple_variant(key, value, info) - for (key, value) in data.iteritems()] + for (key, value) in data.items()] typ = self._make_implicit_enum_type(name, info, [v.name for v in variants]) tag_member = QAPISchemaObjectTypeMember('type', typ, False) @@ -1626,7 +1626,7 @@ class QAPISchema(object): name = expr['alternate'] data = expr['data'] variants = [self._make_variant(key, value) - for (key, value) in data.iteritems()] + for (key, value) in data.items()] tag_member = QAPISchemaObjectTypeMember('type', 'QType', False) self._def_entity( QAPISchemaAlternateType(name, info, doc, diff --git a/scripts/qapi2texi.py b/scripts/qapi2texi.py index 9c57b01bb4..bc43edabd7 100755 --- a/scripts/qapi2texi.py +++ b/scripts/qapi2texi.py @@ -148,7 +148,7 @@ def texi_member(member, suffix=''): def texi_members(doc, what, base, variants, member_func): """Format the table of members""" items = '' - for section in doc.args.itervalues(): + for section in doc.args.values(): # TODO Drop fallbacks when undocumented members are outlawed if section.content: desc = texi_format(str(section)) From patchwork Thu Aug 31 14:24:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 808264 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xjl5s6J7Pz9s83 for ; Fri, 1 Sep 2017 00:25:37 +1000 (AEST) Received: from localhost ([::1]:56042 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnQPX-00083R-SN for incoming@patchwork.ozlabs.org; Thu, 31 Aug 2017 10:25:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43514) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnQOo-0007yS-Gt for qemu-devel@nongnu.org; Thu, 31 Aug 2017 10:24:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dnQOl-0007cz-Br for qemu-devel@nongnu.org; Thu, 31 Aug 2017 10:24:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60716) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dnQOl-0007cf-5F for qemu-devel@nongnu.org; Thu, 31 Aug 2017 10:24:47 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3ADD87EBD3; Thu, 31 Aug 2017 14:24:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3ADD87EBD3 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=berrange@redhat.com Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0138B32B5; Thu, 31 Aug 2017 14:24:42 +0000 (UTC) From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Thu, 31 Aug 2017 15:24:28 +0100 Message-Id: <20170831142430.16665-4-berrange@redhat.com> In-Reply-To: <20170831142430.16665-1-berrange@redhat.com> References: <20170831142430.16665-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 31 Aug 2017 14:24:46 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 3/5] qapi: Use OrderedDict from standard library if available X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , Michael Roth Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" The OrderedDict class appeared in the 'collections' module from python 2.7 onwards, so use that in preference to our local backport if available. Signed-off-by: Daniel P. Berrange --- scripts/qapi.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index d89af7d6c6..05cb1ee38c 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -18,7 +18,10 @@ import os import re import string import sys -from ordereddict import OrderedDict +try: + from collections import OrderedDict +except: + from ordereddict import OrderedDict builtin_types = { 'null': 'QTYPE_QNULL', From patchwork Thu Aug 31 14:24:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 808268 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xjl8s4TkSz9s83 for ; Fri, 1 Sep 2017 00:28:13 +1000 (AEST) Received: from localhost ([::1]:56055 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnQS3-0002EL-ND for incoming@patchwork.ozlabs.org; Thu, 31 Aug 2017 10:28:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43542) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnQOq-00081C-1F for qemu-devel@nongnu.org; Thu, 31 Aug 2017 10:24:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dnQOp-0007f1-3a for qemu-devel@nongnu.org; Thu, 31 Aug 2017 10:24:51 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60454) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dnQOo-0007eb-Tc for qemu-devel@nongnu.org; Thu, 31 Aug 2017 10:24:51 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E8DAB267F7; Thu, 31 Aug 2017 14:24:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com E8DAB267F7 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=berrange@redhat.com Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 987E2B32C3; Thu, 31 Aug 2017 14:24:46 +0000 (UTC) From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Thu, 31 Aug 2017 15:24:29 +0100 Message-Id: <20170831142430.16665-5-berrange@redhat.com> In-Reply-To: <20170831142430.16665-1-berrange@redhat.com> References: <20170831142430.16665-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 31 Aug 2017 14:24:50 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 4/5] qapi: adapt to moved location of StringIO module in py3 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , Michael Roth Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Daniel P. Berrange --- scripts/qapi.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index 05cb1ee38c..3c06711e2c 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -22,6 +22,10 @@ try: from collections import OrderedDict except: from ordereddict import OrderedDict +try: + from StringIO import StringIO +except ImportError: + from io import StringIO builtin_types = { 'null': 'QTYPE_QNULL', @@ -2000,8 +2004,7 @@ def open_output(output_dir, do_c, do_h, prefix, c_file, h_file, if really: return open(name, opt) else: - import StringIO - return StringIO.StringIO() + return StringIO() fdef = maybe_open(do_c, c_file, 'w') fdecl = maybe_open(do_h, h_file, 'w') From patchwork Thu Aug 31 14:24:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= X-Patchwork-Id: 808265 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xjl6W0SYJz9s83 for ; Fri, 1 Sep 2017 00:26:11 +1000 (AEST) Received: from localhost ([::1]:56049 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnQQ5-0000BX-0o for incoming@patchwork.ozlabs.org; Thu, 31 Aug 2017 10:26:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43573) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnQOt-00086r-6m for qemu-devel@nongnu.org; Thu, 31 Aug 2017 10:24:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dnQOs-0007gQ-G0 for qemu-devel@nongnu.org; Thu, 31 Aug 2017 10:24:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60976) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dnQOs-0007gA-9m for qemu-devel@nongnu.org; Thu, 31 Aug 2017 10:24:54 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 520747F755; Thu, 31 Aug 2017 14:24:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 520747F755 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=berrange@redhat.com Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 447FBB32B5; Thu, 31 Aug 2017 14:24:50 +0000 (UTC) From: "Daniel P. Berrange" To: qemu-devel@nongnu.org Date: Thu, 31 Aug 2017 15:24:30 +0100 Message-Id: <20170831142430.16665-6-berrange@redhat.com> In-Reply-To: <20170831142430.16665-1-berrange@redhat.com> References: <20170831142430.16665-1-berrange@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 31 Aug 2017 14:24:53 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 5/5] qapi: Adapt to moved location of 'maketrans' function in py3 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Markus Armbruster , Michael Roth Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Daniel P. Berrange --- scripts/qapi.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/qapi.py b/scripts/qapi.py index 3c06711e2c..853622badd 100644 --- a/scripts/qapi.py +++ b/scripts/qapi.py @@ -1743,7 +1743,10 @@ def c_enum_const(type_name, const_name, prefix=None): type_name = prefix return camel_to_upper(type_name) + '_' + c_name(const_name, False).upper() -c_name_trans = string.maketrans('.-', '__') +if hasattr(str, 'maketrans'): + c_name_trans = str.maketrans('.-', '__') +else: + c_name_trans = string.maketrans('.-', '__') # Map @name to a valid C identifier.