From 57c29397c1a8c720685202e073fc92ef94005bb1 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Tue, 6 Mar 2018 11:26:57 -0500 Subject: [PATCH] qapi: convert to use python print function instead of statement Python 3 no longer supports the bare "print" statement, it must be called as a normal function with round brackets. It is possible to opt-in to this new syntax with Python 2.6 onwards by importing the "print_function" from the "__future__" module, making it easy to support Python 2 and 3 in parallel. Backports commit ef9d9108917d6d5f903bca31602827e512a51c50 from qemu --- qemu/scripts/qapi.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/qemu/scripts/qapi.py b/qemu/scripts/qapi.py index c5b4bc51..7320b597 100644 --- a/qemu/scripts/qapi.py +++ b/qemu/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 @@ -1474,7 +1475,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): @@ -1933,7 +1934,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 = '' @@ -1947,9 +1948,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'): @@ -1966,7 +1966,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]