Skip to contentSkip to conversation

python: futurize --stage1 (Python 3 compatibility)

PATCH In review Eduardo Habkost 3 participants 16 messages Jun 8, 2018 – Jun 11, 2018

lore
Share & tools
lore
#0 lore raw

v2 cover python: futurize --stage1 (Python 3 compatibility)

v2 note (v1 was RFC):

Except for a trivial change in patch 02/10, this series is the same as the RFC I sent previously. I plan to merge it and include it in a pull request soon.

Quoted 14 lines

From the futurize[1] documentation:

This applies fixes that modernize Python 2 code without changing the effect of the code. With luck, this will not introduce any bugs into the code, or will at least be trivial to fix. The changes are those that bring the Python code up-to-date without breaking Py2 compatibility. The resulting code will be modern Python 2.6-compatible code plus __future__ imports from the following set:

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

[...]

Quoted 5 lines

The goal for this stage is to create most of the diff for the entire porting process, but without introducing any bugs. It should be uncontroversial and safe to apply to every Python 2 package. The subsequent patches introducing Python 3 compatibility should then be shorter and easier to review.

This series run all the fixers from futurize --stage1 on all Python code in the tree. To make review and testing easier, I have run the fixers separately instead of doing all changes in a single patch.

[1] http://python-future.org/automatic_conversion.html

Eduardo Habkost (10):
python: futurize -f libfuturize.fixes.fix_print_with_import
python: futurize -f libfuturize.fixes.fix_absolute_import
python: futurize -f libfuturize.fixes.fix_next_call
python: futurize -f lib2to3.fixes.fix_has_key
python: futurize -f lib2to3.fixes.fix_standarderror
python: futurize -f lib2to3.fixes.fix_reduce
python: futurize -f lib2to3.fixes.fix_tuple_params
python: futurize -f lib2to3.fixes.fix_renames
python: futurize -f lib2to3.fixes.fix_except
python: futurize -f lib2to3.fixes.fix_numliterals

 scripts/analyse-9p-simpletrace.py        | 89 ++++++++++++------------
 scripts/analyse-locks-simpletrace.py     |  3 +-
 scripts/analyze-migration.py             | 11 +--
 scripts/dump-guest-memory.py             |  1 +
 scripts/ordereddict.py                   |  4 +-
 scripts/replay-dump.py                   | 21 +++---
 scripts/signrom.py                       |  1 +
 scripts/simpletrace.py                   |  5 +-
 scripts/vmstate-static-checker.py        | 89 ++++++++++++------------
 scripts/device-crash-test                |  3 +-
 scripts/kvm/kvm_flightrecorder           | 21 +++---
 scripts/kvm/vmxcap                       |  1 +
 scripts/qmp/qemu-ga-client               | 10 +--
 scripts/qmp/qmp                          | 24 ++++---
 scripts/qmp/qmp-shell                    | 40 ++++++-----
 scripts/qmp/qom-fuse                     | 11 +--
 scripts/qmp/qom-get                      | 12 ++--
 scripts/qmp/qom-list                     | 16 +++--
 scripts/qmp/qom-set                      | 10 +--
 scripts/qmp/qom-tree                     | 16 +++--
 tests/docker/docker.py                   | 11 +--
 tests/docker/travis.py                   | 15 ++--
 tests/guest-debug/test-gdbstub.py        |  1 +
 tests/image-fuzzer/qcow2/__init__.py     |  3 +-
 tests/image-fuzzer/qcow2/fuzz.py         |  1 +
 tests/image-fuzzer/qcow2/layout.py       |  3 +-
 tests/image-fuzzer/runner.py             | 42 +++++------
 tests/migration/guestperf/engine.py      | 29 ++++----
 tests/migration/guestperf/plot.py        | 17 ++---
 tests/migration/guestperf/shell.py       | 19 ++---
 tests/qemu-iotests/093                   |  2 +-
 tests/qemu-iotests/096                   |  4 +-
 tests/qemu-iotests/118                   | 24 +++----
 tests/qemu-iotests/136                   |  2 +-
 tests/qemu-iotests/149                   |  3 +-
 tests/qemu-iotests/165                   |  3 +-
 tests/qemu-iotests/iotests.py            |  5 +-
 tests/qemu-iotests/nbd-fault-injector.py |  7 +-
 tests/qemu-iotests/qcow2.py              | 39 ++++++-----
 tests/qemu-iotests/qed.py                | 17 ++---
 tests/vm/basevm.py                       |  3 +-
 41 files changed, 337 insertions(+), 301 deletions(-)
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
#1 lore raw

PATCH v2 1/10 python: futurize -f libfuturize.fixes.fix_print_with_import

Change all Python code to use print as a function.

This is necessary for Python 3 compatibility.

Done using:

  $ py=$( (g grep -l -E '^#!.*python';find -name '*.py' -printf '%P\n';) | \
    sort -u | grep -v README.sh4)
  $ futurize -w -f libfuturize.fixes.fix_print_with_import $py
---
 scripts/analyse-9p-simpletrace.py        | 89 ++++++++++++------------
 scripts/analyse-locks-simpletrace.py     |  1 +
 scripts/analyze-migration.py             | 11 +--
 scripts/dump-guest-memory.py             |  1 +
 scripts/replay-dump.py                   | 21 +++---
 scripts/signrom.py                       |  1 +
 scripts/simpletrace.py                   |  3 +-
 scripts/vmstate-static-checker.py        | 85 +++++++++++-----------
 scripts/device-crash-test                |  3 +-
 scripts/kvm/kvm_flightrecorder           | 21 +++---
 scripts/kvm/vmxcap                       |  1 +
 scripts/qmp/qemu-ga-client               |  1 +
 scripts/qmp/qmp                          | 17 ++---
 scripts/qmp/qmp-shell                    | 35 +++++-----
 scripts/qmp/qom-get                      |  7 +-
 scripts/qmp/qom-list                     | 11 +--
 scripts/qmp/qom-set                      |  5 +-
 scripts/qmp/qom-tree                     | 11 +--
 tests/docker/docker.py                   | 11 +--
 tests/docker/travis.py                   | 15 ++--
 tests/guest-debug/test-gdbstub.py        |  1 +
 tests/image-fuzzer/runner.py             | 38 +++++-----
 tests/migration/guestperf/engine.py      | 29 ++++----
 tests/migration/guestperf/plot.py        | 17 ++---
 tests/migration/guestperf/shell.py       | 19 ++---
 tests/qemu-iotests/149                   |  3 +-
 tests/qemu-iotests/165                   |  3 +-
 tests/qemu-iotests/iotests.py            |  5 +-
 tests/qemu-iotests/nbd-fault-injector.py |  7 +-
 tests/qemu-iotests/qcow2.py              | 39 ++++++-----
 tests/qemu-iotests/qed.py                | 17 ++---
 tests/vm/basevm.py                       |  3 +-
 32 files changed, 278 insertions(+), 253 deletions(-)
scripts/analyse-9p-simpletrace.py +45 -44
index 3c3dee4337..710e01adba 100755
@@ -3,6 +3,7 @@
 # Usage: ./analyse-9p-simpletrace <trace-events> <trace-pid>
 #
 # Author: Harsh Prateek Bora
+from __future__ import print_function
 import os
 import simpletrace
 
@@ -79,135 +80,135 @@ symbol_9p = {
 
 class VirtFSRequestTracker(simpletrace.Analyzer):
         def begin(self):
-                print "Pretty printing 9p simpletrace log ..."
+                print("Pretty printing 9p simpletrace log ...")
 
         def v9fs_rerror(self, tag, id, err):
-                print "RERROR (tag =", tag, ", id =", symbol_9p[id], ", err = \"", os.strerror(err), "\")"
+                print("RERROR (tag =", tag, ", id =", symbol_9p[id], ", err = \"", os.strerror(err), "\")")
 
         def v9fs_version(self, tag, id, msize, version):
-                print "TVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")"
+                print("TVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")")
 
         def v9fs_version_return(self, tag, id, msize, version):
-                print "RVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")"
+                print("RVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")")
 
         def v9fs_attach(self, tag, id, fid, afid, uname, aname):
-                print "TATTACH (tag =", tag, ", fid =", fid, ", afid =", afid, ", uname =", uname, ", aname =", aname, ")"
+                print("TATTACH (tag =", tag, ", fid =", fid, ", afid =", afid, ", uname =", uname, ", aname =", aname, ")")
 
         def v9fs_attach_return(self, tag, id, type, version, path):
-                print "RATTACH (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "})"
+                print("RATTACH (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "})")
 
         def v9fs_stat(self, tag, id, fid):
-                print "TSTAT (tag =", tag, ", fid =", fid, ")"
+                print("TSTAT (tag =", tag, ", fid =", fid, ")")
 
         def v9fs_stat_return(self, tag, id, mode, atime, mtime, length):
-                print "RSTAT (tag =", tag, ", mode =", mode, ", atime =", atime, ", mtime =", mtime, ", length =", length, ")"
+                print("RSTAT (tag =", tag, ", mode =", mode, ", atime =", atime, ", mtime =", mtime, ", length =", length, ")")
 
         def v9fs_getattr(self, tag, id, fid, request_mask):
-                print "TGETATTR (tag =", tag, ", fid =", fid, ", request_mask =", hex(request_mask), ")"
+                print("TGETATTR (tag =", tag, ", fid =", fid, ", request_mask =", hex(request_mask), ")")
 
         def v9fs_getattr_return(self, tag, id, result_mask, mode, uid, gid):
-                print "RGETATTR (tag =", tag, ", result_mask =", hex(result_mask), ", mode =", oct(mode), ", uid =", uid, ", gid =", gid, ")"
+                print("RGETATTR (tag =", tag, ", result_mask =", hex(result_mask), ", mode =", oct(mode), ", uid =", uid, ", gid =", gid, ")")
 
         def v9fs_walk(self, tag, id, fid, newfid, nwnames):
-                print "TWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", nwnames =", nwnames, ")"
+                print("TWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", nwnames =", nwnames, ")")
 
         def v9fs_walk_return(self, tag, id, nwnames, qids):
-                print "RWALK (tag =", tag, ", nwnames =", nwnames, ", qids =", hex(qids), ")"
+                print("RWALK (tag =", tag, ", nwnames =", nwnames, ", qids =", hex(qids), ")")
 
         def v9fs_open(self, tag, id, fid, mode):
-                print "TOPEN (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ")"
+                print("TOPEN (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ")")
 
         def v9fs_open_return(self, tag, id, type, version, path, iounit):
-                print "ROPEN (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")"
+                print("ROPEN (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")")
 
         def v9fs_lcreate(self, tag, id, dfid, flags, mode, gid):
-                print "TLCREATE (tag =", tag, ", dfid =", dfid, ", flags =", oct(flags), ", mode =", oct(mode), ", gid =", gid, ")"
+                print("TLCREATE (tag =", tag, ", dfid =", dfid, ", flags =", oct(flags), ", mode =", oct(mode), ", gid =", gid, ")")
 
         def v9fs_lcreate_return(self, tag, id, type, version, path, iounit):
-                print "RLCREATE (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")"
+                print("RLCREATE (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")")
 
         def v9fs_fsync(self, tag, id, fid, datasync):
-                print "TFSYNC (tag =", tag, ", fid =", fid, ", datasync =", datasync, ")"
+                print("TFSYNC (tag =", tag, ", fid =", fid, ", datasync =", datasync, ")")
 
         def v9fs_clunk(self, tag, id, fid):
-                print "TCLUNK (tag =", tag, ", fid =", fid, ")"
+                print("TCLUNK (tag =", tag, ", fid =", fid, ")")
 
         def v9fs_read(self, tag, id, fid, off, max_count):
-                print "TREAD (tag =", tag, ", fid =", fid, ", off =", off, ", max_count =", max_count, ")"
+                print("TREAD (tag =", tag, ", fid =", fid, ", off =", off, ", max_count =", max_count, ")")
 
         def v9fs_read_return(self, tag, id, count, err):
-                print "RREAD (tag =", tag, ", count =", count, ", err =", err, ")"
+                print("RREAD (tag =", tag, ", count =", count, ", err =", err, ")")
 
         def v9fs_readdir(self, tag, id, fid, offset, max_count):
-                print "TREADDIR (tag =", tag, ", fid =", fid, ", offset =", offset, ", max_count =", max_count, ")"
+                print("TREADDIR (tag =", tag, ", fid =", fid, ", offset =", offset, ", max_count =", max_count, ")")
 
         def v9fs_readdir_return(self, tag, id, count, retval):
-                print "RREADDIR (tag =", tag, ", count =", count, ", retval =", retval, ")"
+                print("RREADDIR (tag =", tag, ", count =", count, ", retval =", retval, ")")
 
         def v9fs_write(self, tag, id, fid, off, count, cnt):
-                print "TWRITE (tag =", tag, ", fid =", fid, ", off =", off, ", count =", count, ", cnt =", cnt, ")"
+                print("TWRITE (tag =", tag, ", fid =", fid, ", off =", off, ", count =", count, ", cnt =", cnt, ")")
 
         def v9fs_write_return(self, tag, id, total, err):
-                print "RWRITE (tag =", tag, ", total =", total, ", err =", err, ")"
+                print("RWRITE (tag =", tag, ", total =", total, ", err =", err, ")")
 
         def v9fs_create(self, tag, id, fid, name, perm, mode):
-                print "TCREATE (tag =", tag, ", fid =", fid, ", perm =", oct(perm), ", name =", name, ", mode =", oct(mode), ")"
+                print("TCREATE (tag =", tag, ", fid =", fid, ", perm =", oct(perm), ", name =", name, ", mode =", oct(mode), ")")
 
         def v9fs_create_return(self, tag, id, type, version, path, iounit):
-                print "RCREATE (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")"
+                print("RCREATE (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")")
 
         def v9fs_symlink(self, tag, id, fid, name, symname, gid):
-                print "TSYMLINK (tag =", tag, ", fid =", fid, ", name =", name, ", symname =", symname, ", gid =", gid, ")"
+                print("TSYMLINK (tag =", tag, ", fid =", fid, ", name =", name, ", symname =", symname, ", gid =", gid, ")")
 
         def v9fs_symlink_return(self, tag, id, type, version, path):
-                print "RSYMLINK (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "})"
+                print("RSYMLINK (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "})")
 
         def v9fs_flush(self, tag, id, flush_tag):
-                print "TFLUSH (tag =", tag, ", flush_tag =", flush_tag, ")"
+                print("TFLUSH (tag =", tag, ", flush_tag =", flush_tag, ")")
 
         def v9fs_link(self, tag, id, dfid, oldfid, name):
-                print "TLINK (tag =", tag, ", dfid =", dfid, ", oldfid =", oldfid, ", name =", name, ")"
+                print("TLINK (tag =", tag, ", dfid =", dfid, ", oldfid =", oldfid, ", name =", name, ")")
 
         def v9fs_remove(self, tag, id, fid):
-                print "TREMOVE (tag =", tag, ", fid =", fid, ")"
+                print("TREMOVE (tag =", tag, ", fid =", fid, ")")
 
         def v9fs_wstat(self, tag, id, fid, mode, atime, mtime):
-                print "TWSTAT (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", atime =", atime, "mtime =", mtime, ")"
+                print("TWSTAT (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", atime =", atime, "mtime =", mtime, ")")
 
         def v9fs_mknod(self, tag, id, fid, mode, major, minor):
-                print "TMKNOD (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", major =", major, ", minor =", minor, ")"
+                print("TMKNOD (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", major =", major, ", minor =", minor, ")")
 
         def v9fs_lock(self, tag, id, fid, type, start, length):
-                print "TLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")"
+                print("TLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")")
 
         def v9fs_lock_return(self, tag, id, status):
-                print "RLOCK (tag =", tag, ", status =", status, ")"
+                print("RLOCK (tag =", tag, ", status =", status, ")")
 
         def v9fs_getlock(self, tag, id, fid, type, start, length):
-                print "TGETLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")"
+                print("TGETLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")")
 
         def v9fs_getlock_return(self, tag, id, type, start, length, proc_id):
-                print "RGETLOCK (tag =", tag, "type =", type, ", start =", start, ", length =", length, ", proc_id =", proc_id,  ")"
+                print("RGETLOCK (tag =", tag, "type =", type, ", start =", start, ", length =", length, ", proc_id =", proc_id,  ")")
 
         def v9fs_mkdir(self, tag, id, fid, name, mode, gid):
-                print "TMKDIR (tag =", tag, ", fid =", fid, ", name =", name, ", mode =", mode, ", gid =", gid, ")"
+                print("TMKDIR (tag =", tag, ", fid =", fid, ", name =", name, ", mode =", mode, ", gid =", gid, ")")
 
         def v9fs_mkdir_return(self, tag, id, type, version, path, err):
-                print "RMKDIR (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "}, err =", err, ")"
+                print("RMKDIR (tag =", tag,  ", qid={type =", type, ", version =", version, ", path =", path, "}, err =", err, ")")
 
         def v9fs_xattrwalk(self, tag, id, fid, newfid, name):
-                print "TXATTRWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", xattr name =", name, ")"
+                print("TXATTRWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", xattr name =", name, ")")
 
         def v9fs_xattrwalk_return(self, tag, id, size):
-                print "RXATTRWALK (tag =", tag, ", xattrsize  =", size, ")"
+                print("RXATTRWALK (tag =", tag, ", xattrsize  =", size, ")")
 
         def v9fs_xattrcreate(self, tag, id, fid, name, size, flags):
-                print "TXATTRCREATE (tag =", tag, ", fid =", fid, ", name =", name, ", xattrsize =", size, ", flags =", flags, ")"
+                print("TXATTRCREATE (tag =", tag, ", fid =", fid, ", name =", name, ", xattrsize =", size, ", flags =", flags, ")")
 
         def v9fs_readlink(self, tag, id, fid):
-                print "TREADLINK (tag =", tag, ", fid =", fid, ")"
+                print("TREADLINK (tag =", tag, ", fid =", fid, ")")
 
         def v9fs_readlink_return(self, tag, id, target):
-                print "RREADLINK (tag =", tag, ", target =", target, ")"
+                print("RREADLINK (tag =", tag, ", target =", target, ")")
 
 simpletrace.run(VirtFSRequestTracker())
scripts/analyse-locks-simpletrace.py +1 -0
index 101e84dea5..352bc9c22d 100755
@@ -6,6 +6,7 @@
 # Author: Alex Bennée <[email protected]>
 #
 
+from __future__ import print_function
 import os
 import simpletrace
 import argparse
scripts/analyze-migration.py +6 -5
index 88ff4adb30..5c2010c917 100755
@@ -17,6 +17,7 @@
 # You should have received a copy of the GNU Lesser General Public
 # License along with this library; if not, see <http://www.gnu.org/licenses/>.
 
+from __future__ import print_function
 import numpy as np
 import json
 import os
@@ -162,7 +163,7 @@ class RamSection(object):
                     len = self.file.read64()
                     self.sizeinfo[self.name] = '0x%016x' % len
                     if self.write_memory:
-                        print self.name
+                        print(self.name)
                         mkdir_p('./' + os.path.dirname(self.name))
                         f = open('./' + self.name, "wb")
                         f.truncate(0)
@@ -588,7 +589,7 @@ if args.extract:
     dump = MigrationDump(args.file)
 
     dump.read(desc_only = True)
-    print "desc.json"
+    print("desc.json")
     f = open("desc.json", "wb")
     f.truncate()
     f.write(jsonenc.encode(dump.vmsd_desc))
@@ -596,7 +597,7 @@ if args.extract:
 
     dump.read(write_memory = True)
     dict = dump.getDict()
-    print "state.json"
+    print("state.json")
     f = open("state.json", "wb")
     f.truncate()
     f.write(jsonenc.encode(dict))
@@ -605,10 +606,10 @@ elif args.dump == "state":
     dump = MigrationDump(args.file)
     dump.read(dump_memory = args.memory)
     dict = dump.getDict()
-    print jsonenc.encode(dict)
+    print(jsonenc.encode(dict))
 elif args.dump == "desc":
     dump = MigrationDump(args.file)
     dump.read(desc_only = True)
-    print jsonenc.encode(dump.vmsd_desc)
+    print(jsonenc.encode(dump.vmsd_desc))
 else:
     raise Exception("Please specify either -x, -d state or -d dump")
scripts/dump-guest-memory.py +1 -0
index 276eebf0c2..5a857cebcf 100644
@@ -12,6 +12,7 @@ Authors:
 This work is licensed under the terms of the GNU GPL, version 2 or later. See
 the COPYING file in the top-level directory.
 """
+from __future__ import print_function
 
 import ctypes
 import struct
scripts/replay-dump.py +11 -10
index e274086277..5ae77c8a92 100755
@@ -18,6 +18,7 @@
 # You should have received a copy of the GNU Lesser General Public
 # License along with this library; if not, see <http://www.gnu.org/licenses/>.
 
+from __future__ import print_function
 import argparse
 import struct
 from collections import namedtuple
@@ -89,9 +90,9 @@ def call_decode(table, index, dumpfile):
     "Search decode table for next step"
     decoder = next((d for d in table if d.eid == index), None)
     if not decoder:
-        print "Could not decode index: %d" % (index)
-        print "Entry is: %s" % (decoder)
-        print "Decode Table is:\n%s" % (table)
+        print("Could not decode index: %d" % (index))
+        print("Entry is: %s" % (decoder))
+        print("Decode Table is:\n%s" % (table))
         return False
     else:
         return decoder.fn(decoder.eid, decoder.name, dumpfile)
@@ -103,23 +104,23 @@ def print_event(eid, name, string=None, event_count=None):
         event_count = replay_state.event_count
 
     if string:
-        print "%d:%s(%d) %s" % (event_count, name, eid, string)
+        print("%d:%s(%d) %s" % (event_count, name, eid, string))
     else:
-        print "%d:%s(%d)" % (event_count, name, eid)
+        print("%d:%s(%d)" % (event_count, name, eid))
 
 
 # Decoders for each event type
 
 def decode_unimp(eid, name, _unused_dumpfile):
     "Unimplimented decoder, will trigger exit"
-    print "%s not handled - will now stop" % (name)
+    print("%s not handled - will now stop" % (name))
     return False
 
 # Checkpoint decoder
 def swallow_async_qword(eid, name, dumpfile):
     "Swallow a qword of data without looking at it"
     step_id = read_qword(dumpfile)
-    print "  %s(%d) @ %d" % (name, eid, step_id)
+    print("  %s(%d) @ %d" % (name, eid, step_id))
     return True
 
 async_decode_table = [ Decoder(0, "REPLAY_ASYNC_EVENT_BH", swallow_async_qword),
@@ -139,8 +140,8 @@ def decode_async(eid, name, dumpfile):
     async_event_checkpoint = read_byte(dumpfile)
 
     if async_event_checkpoint != replay_state.current_checkpoint:
-        print "  mismatch between checkpoint %d and async data %d" % (
-            replay_state.current_checkpoint, async_event_checkpoint)
+        print("  mismatch between checkpoint %d and async data %d" % (
+            replay_state.current_checkpoint, async_event_checkpoint))
         return True
 
     return call_decode(async_decode_table, async_event_kind, dumpfile)
@@ -283,7 +284,7 @@ def decode_file(filename):
     version = read_dword(dumpfile)
     junk = read_qword(dumpfile)
 
-    print "HEADER: version 0x%x" % (version)
+    print("HEADER: version 0x%x" % (version))
 
     if version == 0xe02007:
         event_decode_table = v7_event_table
scripts/signrom.py +1 -0
index 0497a1c32e..313ee28a17 100644
@@ -1,3 +1,4 @@
+from __future__ import print_function
 #
 # Option ROM signing utility
 #
scripts/simpletrace.py +2 -1
index 9d45c6ba4e..2658b5cc7c 100755
@@ -9,6 +9,7 @@
 #
 # For help see docs/devel/tracing.txt
 
+from __future__ import print_function
 import struct
 import re
 import inspect
@@ -257,6 +258,6 @@ if __name__ == '__main__':
                 else:
                     fields.append('%s=0x%x' % (name, rec[i]))
                 i += 1
-            print ' '.join(fields)
+            print(' '.join(fields))
 
     run(Formatter())
scripts/vmstate-static-checker.py +43 -42

176 lines not on this page · raw message

scripts/device-crash-test +2 -1
index b3ce72069f..e6c233e9bf 100755
@@ -23,6 +23,7 @@
 Run QEMU with all combinations of -machine and -device types,
 check for crashes and unexpected errors.
 """
+from __future__ import print_function
 
 import sys
 import os
@@ -554,7 +555,7 @@ def main():
                 tc[k] = v
 
     if len(binariesToTest(args, tc)) == 0:
-        print >>sys.stderr, "No QEMU binary found"
+        print("No QEMU binary found", file=sys.stderr)
         parser.print_usage(sys.stderr)
         return 1
 
scripts/kvm/kvm_flightrecorder +11 -10
index 7fb1c2d1a7..54a56745e4 100755
@@ -32,6 +32,7 @@
 # consuming CPU cycles.  No disk I/O is performed since the ring buffer holds a
 # fixed-size in-memory trace.
 
+from __future__ import print_function
 import sys
 import os
 
@@ -77,8 +78,8 @@ def tail_trace():
         pass
 
 def usage():
-    print 'Usage: %s start [buffer_size_kb] | stop | dump | tail' % sys.argv[0]
-    print 'Control the KVM flight recorder tracing.'
+    print('Usage: %s start [buffer_size_kb] | stop | dump | tail' % sys.argv[0])
+    print('Control the KVM flight recorder tracing.')
     sys.exit(0)
 
 def main():
@@ -87,15 +88,15 @@ def main():
 
     cmd = sys.argv[1]
     if cmd == '--version':
-        print 'kvm_flightrecorder version 1.0'
+        print('kvm_flightrecorder version 1.0')
         sys.exit(0)
 
     if not os.path.isdir(tracing_dir):
-        print 'Unable to tracing debugfs directory, try:'
-        print 'mount -t debugfs none /sys/kernel/debug'
+        print('Unable to tracing debugfs directory, try:')
+        print('mount -t debugfs none /sys/kernel/debug')
         sys.exit(1)
     if not os.access(tracing_dir, os.W_OK):
-        print 'Unable to write to tracing debugfs directory, please run as root'
+        print('Unable to write to tracing debugfs directory, please run as root')
         sys.exit(1)
 
     if cmd == 'start':
@@ -105,16 +106,16 @@ def main():
             try:
                 buffer_size_kb = int(sys.argv[2])
             except ValueError:
-                print 'Invalid per-cpu trace buffer size in KB'
+                print('Invalid per-cpu trace buffer size in KB')
                 sys.exit(1)
             write_file(trace_path('buffer_size_kb'), str(buffer_size_kb))
-            print 'Per-CPU ring buffer size set to %d KB' % buffer_size_kb
+            print('Per-CPU ring buffer size set to %d KB' % buffer_size_kb)
 
         start_tracing()
-        print 'KVM flight recorder enabled'
+        print('KVM flight recorder enabled')
     elif cmd == 'stop':
         stop_tracing()
-        print 'KVM flight recorder disabled'
+        print('KVM flight recorder disabled')
     elif cmd == 'dump':
         dump_trace()
     elif cmd == 'tail':
scripts/kvm/vmxcap +1 -0
index d9a6db0bb7..99a8146aaa 100755
@@ -10,6 +10,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
 MSR_IA32_VMX_BASIC = 0x480
 MSR_IA32_VMX_PINBASED_CTLS = 0x481
 MSR_IA32_VMX_PROCBASED_CTLS = 0x482
scripts/qmp/qemu-ga-client +1 -0
index 7d2a472094..8510814683 100755
@@ -36,6 +36,7 @@
 # See also: https://wiki.qemu.org/Features/QAPI/GuestAgent
 #
 
+from __future__ import print_function
 import base64
 import random
 
scripts/qmp/qmp +9 -8
index 514b539a6b..16d3bdb6fe 100755
@@ -10,6 +10,7 @@
 # This work is licensed under the terms of the GNU GPLv2 or later.
 # See the COPYING file in the top-level directory.
 
+from __future__ import print_function
 import sys, os
 from qmp import QEMUMonitorProtocol
 
@@ -26,9 +27,9 @@ def print_response(rsp, prefix=[]):
             print_response(rsp[key], prefix + [key])
     else:
         if len(prefix):
-            print '%s: %s' % ('.'.join(prefix), rsp)
+            print('%s: %s' % ('.'.join(prefix), rsp))
         else:
-            print '%s' % (rsp)
+            print('%s' % (rsp))
 
 def main(args):
     path = None
@@ -53,21 +54,21 @@ def main(args):
             elif arg in ['help']:
                 os.execlp('man', 'man', 'qmp')
             else:
-                print 'Unknown argument "%s"' % arg
+                print('Unknown argument "%s"' % arg)
 
             args = args[1:]
         else:
             break
 
     if not path:
-        print "QMP path isn't set, use --path=qmp-monitor-address or set QMP_PATH"
+        print("QMP path isn't set, use --path=qmp-monitor-address or set QMP_PATH")
         return 1
 
     if len(args):
         command, args = args[0], args[1:]
     else:
-        print 'No command found'
-        print 'Usage: "qmp [--path=qmp-monitor-address] qmp-cmd arguments"'
+        print('No command found')
+        print('Usage: "qmp [--path=qmp-monitor-address] qmp-cmd arguments"')
         return 1
 
     if command in ['help']:
@@ -93,7 +94,7 @@ def main(args):
             os.execvp(fullcmd, [fullcmd] + args)
         except OSError as exc:
             if exc.errno == 2:
-                print 'Command "%s" not found.' % (fullcmd)
+                print('Command "%s" not found.' % (fullcmd))
                 return 1
             raise
         return 0
@@ -104,7 +105,7 @@ def main(args):
     arguments = {}
     for arg in args:
         if not arg.startswith('--'):
-            print 'Unknown argument "%s"' % arg
+            print('Unknown argument "%s"' % arg)
             return 1
 
         arg = arg[2:]
scripts/qmp/qmp-shell +18 -17
index be449de621..b1cc7e2271 100755
@@ -65,6 +65,7 @@
 # which will echo back the properly formatted JSON-compliant QMP that is being
 # sent to QEMU, which is useful for debugging and documentation generation.
 
+from __future__ import print_function
 import qmp
 import json
 import ast
@@ -153,14 +154,14 @@ class QMPShell(qmp.QEMUMonitorProtocol):
                 # File not found. No problem.
                 pass
             else:
-                print "Failed to read history '%s'; %s" % (self._histfile, e)
+                print("Failed to read history '%s'; %s" % (self._histfile, e))
         atexit.register(self.__save_history)
 
     def __save_history(self):
         try:
             readline.write_history_file(self._histfile)
         except Exception as e:
-            print "Failed to save history file '%s'; %s" % (self._histfile, e)
+            print("Failed to save history file '%s'; %s" % (self._histfile, e))
 
     def __parse_value(self, val):
         try:
@@ -258,15 +259,15 @@ class QMPShell(qmp.QEMUMonitorProtocol):
         if self._pretty:
             indent = 4
         jsobj = json.dumps(qmp, indent=indent)
-        print str(jsobj)
+        print(str(jsobj))
 
     def _execute_cmd(self, cmdline):
         try:
             qmpcmd = self.__build_cmd(cmdline)
         except Exception as e:
-            print 'Error while parsing command line: %s' % e
-            print 'command format: <command-name> ',
-            print '[arg-name1=arg1] ... [arg-nameN=argN]'
+            print('Error while parsing command line: %s' % e)
+            print('command format: <command-name> ', end=' ')
+            print('[arg-name1=arg1] ... [arg-nameN=argN]')
             return True
         # For transaction mode, we may have just cached the action:
         if qmpcmd is None:
@@ -275,7 +276,7 @@ class QMPShell(qmp.QEMUMonitorProtocol):
             self._print(qmpcmd)
         resp = self.cmd_obj(qmpcmd)
         if resp is None:
-            print 'Disconnected'
+            print('Disconnected')
             return False
         self._print(resp)
         return True
@@ -285,12 +286,12 @@ class QMPShell(qmp.QEMUMonitorProtocol):
         self.__completer_setup()
 
     def show_banner(self, msg='Welcome to the QMP low-level shell!'):
-        print msg
+        print(msg)
         if not self._greeting:
-            print 'Connected'
+            print('Connected')
             return
         version = self._greeting['QMP']['version']['qemu']
-        print 'Connected to QEMU %d.%d.%d\n' % (version['major'],version['minor'],version['micro'])
+        print('Connected to QEMU %d.%d.%d\n' % (version['major'],version['minor'],version['micro']))
 
     def get_prompt(self):
         if self._transmode:
@@ -306,11 +307,11 @@ class QMPShell(qmp.QEMUMonitorProtocol):
         try:
             cmdline = raw_input(prompt)
         except EOFError:
-            print
+            print()
             return False
         if cmdline == '':
             for ev in self.get_events():
-                print ev
+                print(ev)
             self.clear_events()
             return True
         else:
@@ -366,24 +367,24 @@ class HMPShell(QMPShell):
             try:
                 idx = int(cmdline.split()[1])
                 if not 'return' in self.__cmd_passthrough('info version', idx):
-                    print 'bad CPU index'
+                    print('bad CPU index')
                     return True
                 self.__cpu_index = idx
             except ValueError:
-                print 'cpu command takes an integer argument'
+                print('cpu command takes an integer argument')
                 return True
         resp = self.__cmd_passthrough(cmdline, self.__cpu_index)
         if resp is None:
-            print 'Disconnected'
+            print('Disconnected')
             return False
         assert 'return' in resp or 'error' in resp
         if 'return' in resp:
             # Success
             if len(resp['return']) > 0:
-                print resp['return'],
+                print(resp['return'], end=' ')
         else:
             # Error
-            print '%s: %s' % (resp['error']['class'], resp['error']['desc'])
+            print('%s: %s' % (resp['error']['class'], resp['error']['desc']))
         return True
 
     def show_banner(self):
scripts/qmp/qom-get +4 -3
index 0172c69441..291c8bfbc2 100755
@@ -11,6 +11,7 @@
 # the COPYING file in the top-level directory.
 ##
 
+from __future__ import print_function
 import sys
 import os
 from qmp import QEMUMonitorProtocol
@@ -33,7 +34,7 @@ def usage_error(error_msg = "unspecified error"):
 
 if len(args) > 0:
     if args[0] == "-h":
-        print usage()
+        print(usage())
         exit(0);
     elif args[0] == "-s":
         try:
@@ -62,6 +63,6 @@ srv.connect()
 rsp = srv.command('qom-get', path=path, property=prop)
 if type(rsp) == dict:
     for i in rsp.keys():
-        print '%s: %s' % (i, rsp[i])
+        print('%s: %s' % (i, rsp[i]))
 else:
-    print rsp
+    print(rsp)
scripts/qmp/qom-list +6 -5
index 1e7cc6cb2d..cd907bb81f 100755
@@ -11,6 +11,7 @@
 # the COPYING file in the top-level directory.
 ##
 
+from __future__ import print_function
 import sys
 import os
 from qmp import QEMUMonitorProtocol
@@ -33,7 +34,7 @@ def usage_error(error_msg = "unspecified error"):
 
 if len(args) > 0:
     if args[0] == "-h":
-        print usage()
+        print(usage())
         exit(0);
     elif args[0] == "-s":
         try:
@@ -52,13 +53,13 @@ srv = QEMUMonitorProtocol(socket_path)
 srv.connect()
 
 if len(args) == 0:
-    print '/'
+    print('/')
     sys.exit(0)
 
 for item in srv.command('qom-list', path=args[0]):
     if item['type'].startswith('child<'):
-        print '%s/' % item['name']
+        print('%s/' % item['name'])
     elif item['type'].startswith('link<'):
-        print '@%s/' % item['name']
+        print('@%s/' % item['name'])
     else:
-        print '%s' % item['name']
+        print('%s' % item['name'])
scripts/qmp/qom-set +3 -2
index 94e2778922..fbe4b3e471 100755
@@ -11,6 +11,7 @@
 # the COPYING file in the top-level directory.
 ##
 
+from __future__ import print_function
 import sys
 import os
 from qmp import QEMUMonitorProtocol
@@ -34,7 +35,7 @@ def usage_error(error_msg = "unspecified error"):
 
 if len(args) > 0:
     if args[0] == "-h":
-        print usage()
+        print(usage())
         exit(0);
     elif args[0] == "-s":
         try:
@@ -61,4 +62,4 @@ else:
 srv = QEMUMonitorProtocol(socket_path)
 srv.connect()
 
-print srv.command('qom-set', path=path, property=prop, value=value)
+print(srv.command('qom-set', path=path, property=prop, value=value))
scripts/qmp/qom-tree +6 -5
index 906fcd2640..0ffd1ff1de 100755
@@ -13,6 +13,7 @@
 # the COPYING file in the top-level directory.
 ##
 
+from __future__ import print_function
 import sys
 import os
 from qmp import QEMUMonitorProtocol
@@ -35,7 +36,7 @@ def usage_error(error_msg = "unspecified error"):
 
 if len(args) > 0:
     if args[0] == "-h":
-        print usage()
+        print(usage())
         exit(0);
     elif args[0] == "-s":
         try:
@@ -54,15 +55,15 @@ srv = QEMUMonitorProtocol(socket_path)
 srv.connect()
 
 def list_node(path):
-    print '%s' % path
+    print('%s' % path)
     items = srv.command('qom-list', path=path)
     for item in items:
         if not item['type'].startswith('child<'):
             try:
-                print '  %s: %s (%s)' % (item['name'], srv.command('qom-get', path=path, property=item['name']), item['type'])
+                print('  %s: %s (%s)' % (item['name'], srv.command('qom-get', path=path, property=item['name']), item['type']))
             except:
-                print '  %s: <EXCEPTION> (%s)' % (item['name'], item['type'])
-    print ''
+                print('  %s: <EXCEPTION> (%s)' % (item['name'], item['type']))
+    print('')
     for item in items:
         if item['type'].startswith('child<'):
             list_node((path if (path != '/') else '')  + '/' + item['name'])
tests/docker/docker.py +6 -5
index f8267586eb..a18cfcbe94 100755
@@ -11,6 +11,7 @@
 # or (at your option) any later version. See the COPYING file in
 # the top-level directory.
 
+from __future__ import print_function
 import os
 import sys
 sys.path.append(os.path.join(os.path.dirname(__file__),
@@ -87,7 +88,7 @@ def _get_so_libs(executable):
                 so_lib = search.groups()[1]
                 libs.append("%s/%s" % (so_path, so_lib))
     except subprocess.CalledProcessError:
-        print "%s had no associated libraries (static build?)" % (executable)
+        print("%s had no associated libraries (static build?)" % (executable))
 
     return libs
 
@@ -161,7 +162,7 @@ class Docker(object):
                 continue
             if only_known and instance_uuid not in self._instances:
                 continue
-            print "Terminating", i
+            print("Terminating", i)
             if active:
                 self._do(["kill", i])
             self._do(["rm", i])
@@ -288,7 +289,7 @@ class BuildCommand(SubCommand):
         if "--no-cache" not in argv and \
            dkr.image_matches_dockerfile(tag, dockerfile):
             if not args.quiet:
-                print "Image is up to date."
+                print("Image is up to date.")
         else:
             # Create a docker context directory for the build
             docker_dir = tempfile.mkdtemp(prefix="docker_build")
@@ -300,10 +301,10 @@ class BuildCommand(SubCommand):
                 rc = subprocess.call(os.path.realpath(docker_pre),
                                      cwd=docker_dir, stdout=stdout)
                 if rc == 3:
-                    print "Skip"
+                    print("Skip")
                     return 0
                 elif rc != 0:
-                    print "%s exited with code %d" % (docker_pre, rc)
+                    print("%s exited with code %d" % (docker_pre, rc))
                     return 1
 
             # Copy any extra files into the Docker context. These can be
tests/docker/travis.py +8 -7
index 703a7fde85..ea1ef169e6 100755
@@ -11,6 +11,7 @@
 # or (at your option) any later version. See the COPYING file in
 # the top-level directory.
 
+from __future__ import print_function
 import sys
 import yaml
 import itertools
@@ -34,14 +35,14 @@ def main():
         sys.stderr.write("Usage: %s <travis-file>\n" % sys.argv[0])
         return 1
     conf = load_yaml(sys.argv[1])
-    print "\n".join((": ${%s}" % var for var in conf["env"]["global"]))
+    print("\n".join((": ${%s}" % var for var in conf["env"]["global"])))
     for config in conf_iter(conf):
-        print "("
-        print "\n".join(config["env"])
-        print "alias cc=" + config["compiler"]
-        print "\n".join(conf["before_script"])
-        print "\n".join(conf["script"])
-        print ")"
+        print("(")
+        print("\n".join(config["env"]))
+        print("alias cc=" + config["compiler"])
+        print("\n".join(conf["before_script"]))
+        print("\n".join(conf["script"]))
+        print(")")
     return 0
 
 if __name__ == "__main__":
tests/guest-debug/test-gdbstub.py +1 -0
index 31ba6c943a..474d2c5c65 100644
@@ -1,3 +1,4 @@
+from __future__ import print_function
 #
 # This script needs to be run on startup
 # qemu -kernel ${KERNEL} -s -S
tests/image-fuzzer/runner.py +16 -22
index 96a1c11b2f..8de656933e 100755
@@ -18,6 +18,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
+from __future__ import print_function
 import sys
 import os
 import signal
@@ -36,9 +37,8 @@ except ImportError:
     try:
         import simplejson as json
     except ImportError:
-        print >>sys.stderr, \
-            "Warning: Module for JSON processing is not found.\n" \
-            "'--config' and '--command' options are not supported."
+        print("Warning: Module for JSON processing is not found.\n" \
+            "'--config' and '--command' options are not supported.", file=sys.stderr)
 
 # Backing file sizes in MB
 MAX_BACKING_FILE_SIZE = 10
@@ -158,9 +158,8 @@ class TestEnv(object):
         try:
             os.makedirs(self.current_dir)
         except OSError as e:
-            print >>sys.stderr, \
-                "Error: The working directory '%s' cannot be used. Reason: %s"\
-                % (self.work_dir, e[1])
+            print("Error: The working directory '%s' cannot be used. Reason: %s"\
+                % (self.work_dir, e[1]), file=sys.stderr)
             raise TestException
         self.log = open(os.path.join(self.current_dir, "test.log"), "w")
         self.parent_log = open(run_log, "a")
@@ -277,7 +276,7 @@ class TestEnv(object):
 if __name__ == '__main__':
 
     def usage():
-        print """
+        print("""
         Usage: runner.py [OPTION...] TEST_DIR IMG_GENERATOR
 
         Set up test environment in TEST_DIR and run a test in it. A module for
@@ -326,7 +325,7 @@ if __name__ == '__main__':
 
         If '--config' argument is specified, fields not listed in
         the configuration array will not be fuzzed.
-        """
+        """)
 
     def run_test(test_id, seed, work_dir, run_log, cleanup, log_all,
                  command, fuzz_config):
@@ -357,8 +356,7 @@ if __name__ == '__main__':
                                        ['command=', 'help', 'seed=', 'config=',
                                         'keep_passed', 'verbose', 'duration='])
     except getopt.error as e:
-        print >>sys.stderr, \
-            "Error: %s\n\nTry 'runner.py --help' for more information" % e
+        print("Error: %s\n\nTry 'runner.py --help' for more information" % e, file=sys.stderr)
         sys.exit(1)
 
     command = None
@@ -375,9 +373,8 @@ if __name__ == '__main__':
             try:
                 command = json.loads(arg)
             except (TypeError, ValueError, NameError) as e:
-                print >>sys.stderr, \
-                    "Error: JSON array of test commands cannot be loaded.\n" \
-                    "Reason: %s" % e
+                print("Error: JSON array of test commands cannot be loaded.\n" \
+                    "Reason: %s" % e, file=sys.stderr)
                 sys.exit(1)
         elif opt in ('-k', '--keep_passed'):
             cleanup = False
@@ -391,15 +388,13 @@ if __name__ == '__main__':
             try:
                 config = json.loads(arg)
             except (TypeError, ValueError, NameError) as e:
-                print >>sys.stderr, \
-                    "Error: JSON array with the fuzzer configuration cannot" \
-                    " be loaded\nReason: %s" % e
+                print("Error: JSON array with the fuzzer configuration cannot" \
+                    " be loaded\nReason: %s" % e, file=sys.stderr)
                 sys.exit(1)
 
     if not len(args) == 2:
-        print >>sys.stderr, \
-            "Expected two parameters\nTry 'runner.py --help'" \
-            " for more information."
+        print("Expected two parameters\nTry 'runner.py --help'" \
+            " for more information.", file=sys.stderr)
         sys.exit(1)
 
     work_dir = os.path.realpath(args[0])
@@ -415,9 +410,8 @@ if __name__ == '__main__':
     try:
         image_generator = __import__(generator_name)
     except ImportError as e:
-        print >>sys.stderr, \
-            "Error: The image generator '%s' cannot be imported.\n" \
-            "Reason: %s" % (generator_name, e)
+        print("Error: The image generator '%s' cannot be imported.\n" \
+            "Reason: %s" % (generator_name, e), file=sys.stderr)
         sys.exit(1)
 
     # Enable core dumps
tests/migration/guestperf/engine.py +15 -14
index e14d4320b2..398e3f2706 100644
@@ -1,3 +1,4 @@
+from __future__ import print_function
 #
 # Migration test main engine
 #
@@ -117,7 +118,7 @@ class Engine(object):
         # XXX how to get dst timings on remote host ?
 
         if self._verbose:
-            print "Sleeping %d seconds for initial guest workload run" % self._sleep
+            print("Sleeping %d seconds for initial guest workload run" % self._sleep)
         sleep_secs = self._sleep
         while sleep_secs > 1:
             src_qemu_time.append(self._cpu_timing(src_pid))
@@ -126,7 +127,7 @@ class Engine(object):
             sleep_secs -= 1
 
         if self._verbose:
-            print "Starting migration"
+            print("Starting migration")
         if scenario._auto_converge:
             resp = src.command("migrate-set-capabilities",
                                capabilities = [
@@ -216,7 +217,7 @@ class Engine(object):
 
                 if progress._status == "completed":
                     if self._verbose:
-                        print "Sleeping %d seconds for final guest workload run" % self._sleep
+                        print("Sleeping %d seconds for final guest workload run" % self._sleep)
                     sleep_secs = self._sleep
                     while sleep_secs > 1:
                         time.sleep(1)
@@ -227,23 +228,23 @@ class Engine(object):
                 return [progress_history, src_qemu_time, src_vcpu_time]
 
             if self._verbose and (loop % 20) == 0:
-                print "Iter %d: remain %5dMB of %5dMB (total %5dMB @ %5dMb/sec)" % (
+                print("Iter %d: remain %5dMB of %5dMB (total %5dMB @ %5dMb/sec)" % (
                     progress._ram._iterations,
                     progress._ram._remaining_bytes / (1024 * 1024),
                     progress._ram._total_bytes / (1024 * 1024),
                     progress._ram._transferred_bytes / (1024 * 1024),
                     progress._ram._transfer_rate_mbs,
-                )
+                ))
 
             if progress._ram._iterations > scenario._max_iters:
                 if self._verbose:
-                    print "No completion after %d iterations over RAM" % scenario._max_iters
+                    print("No completion after %d iterations over RAM" % scenario._max_iters)
                 src.command("migrate_cancel")
                 continue
 
             if time.time() > (start + scenario._max_time):
                 if self._verbose:
-                    print "No completion after %d seconds" % scenario._max_time
+                    print("No completion after %d seconds" % scenario._max_time)
                 src.command("migrate_cancel")
                 continue
 
@@ -251,7 +252,7 @@ class Engine(object):
                 progress._ram._iterations >= scenario._post_copy_iters and
                 not post_copy):
                 if self._verbose:
-                    print "Switching to post-copy after %d iterations" % scenario._post_copy_iters
+                    print("Switching to post-copy after %d iterations" % scenario._post_copy_iters)
                 resp = src.command("migrate-start-postcopy")
                 post_copy = True
 
@@ -259,7 +260,7 @@ class Engine(object):
                 progress._ram._iterations >= scenario._pause_iters and
                 not paused):
                 if self._verbose:
-                    print "Pausing VM after %d iterations" % scenario._pause_iters
+                    print("Pausing VM after %d iterations" % scenario._pause_iters)
                 resp = src.command("stop")
                 paused = True
 
@@ -348,7 +349,7 @@ class Engine(object):
         if not log:
             return []
         if self._debug:
-            print log
+            print(log)
 
         regex = r"[^\s]+\s\((\d+)\):\sINFO:\s(\d+)ms\scopied\s\d+\sGB\sin\s(\d+)ms"
         matcher = re.compile(regex)
@@ -407,7 +408,7 @@ class Engine(object):
             if uri[0:5] == "unix:":
                 os.remove(uri[5:])
             if self._verbose:
-                print "Finished migration"
+                print("Finished migration")
 
             src.shutdown()
             dst.shutdown()
@@ -420,7 +421,7 @@ class Engine(object):
                           self._initrd, self._transport, self._sleep)
         except Exception as e:
             if self._debug:
-                print "Failed: %s" % str(e)
+                print("Failed: %s" % str(e))
             try:
                 src.shutdown()
             except:
@@ -431,7 +432,7 @@ class Engine(object):
                 pass
 
             if self._debug:
-                print src.get_log()
-                print dst.get_log()
+                print(src.get_log())
+                print(dst.get_log())
             raise
 
tests/migration/guestperf/plot.py +9 -8
index bc42249e16..aa98912a82 100644
@@ -1,3 +1,4 @@
+from __future__ import print_function
 #
 # Migration test graph plotting
 #
@@ -588,7 +589,7 @@ class Plot(object):
 """
 
     def generate_html(self, fh):
-        print >>fh, """<html>
+        print("""<html>
   <head>
     <script type="text/javascript" src="plotly.min.js">
     </script>
@@ -601,19 +602,19 @@ class Plot(object):
     <h1>Migration report</h1>
     <h2>Chart summary</h2>
     <div id="chart">
-""" % self._generate_style()
-        print >>fh, self._generate_chart()
-        print >>fh, """
+""" % self._generate_style(), file=fh)
+        print(self._generate_chart(), file=fh)
+        print("""
     </div>
     <h2>Report details</h2>
     <div id="report">
-"""
-        print >>fh, self._generate_report()
-        print >>fh, """
+""", file=fh)
+        print(self._generate_report(), file=fh)
+        print("""
     </div>
   </body>
 </html>
-"""
+""", file=fh)
 
     def generate(self, filename):
         if filename is None:
tests/migration/guestperf/shell.py +10 -9
index b272978f47..a6b8cec1e0 100644
@@ -1,3 +1,4 @@
+from __future__ import print_function
 #
 # Migration test command line shell integration
 #
@@ -160,13 +161,13 @@ class Shell(BaseShell):
         try:
             report = engine.run(hardware, scenario)
             if args.output is None:
-                print report.to_json()
+                print(report.to_json())
             else:
                 with open(args.output, "w") as fh:
-                    print >>fh, report.to_json()
+                    print(report.to_json(), file=fh)
             return 0
         except Exception as e:
-            print >>sys.stderr, "Error: %s" % str(e)
+            print("Error: %s" % str(e), file=sys.stderr)
             if args.debug:
                 raise
             return 1
@@ -199,11 +200,11 @@ class BatchShell(BaseShell):
                     name = os.path.join(comparison._name, scenario._name)
                     if not fnmatch.fnmatch(name, args.filter):
                         if args.verbose:
-                            print "Skipping %s" % name
+                            print("Skipping %s" % name)
                         continue
 
                     if args.verbose:
-                        print "Running %s" % name
+                        print("Running %s" % name)
 
                     dirname = os.path.join(args.output, comparison._name)
                     filename = os.path.join(dirname, scenario._name + ".json")
@@ -211,9 +212,9 @@ class BatchShell(BaseShell):
                         os.makedirs(dirname)
                     report = engine.run(hardware, scenario)
                     with open(filename, "w") as fh:
-                        print >>fh, report.to_json()
+                        print(report.to_json(), file=fh)
         except Exception as e:
-            print >>sys.stderr, "Error: %s" % str(e)
+            print("Error: %s" % str(e), file=sys.stderr)
             if args.debug:
                 raise
 
@@ -246,14 +247,14 @@ class PlotShell(object):
 
 
         if len(args.reports) == 0:
-            print >>sys.stderr, "At least one report required"
+            print("At least one report required", file=sys.stderr)
             return 1
 
         if not (args.qemu_cpu or
                 args.vcpu_cpu or
                 args.total_guest_cpu or
                 args.split_guest_cpu):
-            print >>sys.stderr, "At least one chart type is required"
+            print("At least one chart type is required", file=sys.stderr)
             return 1
 
         reports = []
tests/qemu-iotests/149 +2 -1
index 223cd68ad5..d3ffa259db 100755
@@ -20,6 +20,7 @@
 # Exercise the QEMU 'luks' block driver to validate interoperability
 # with the Linux dm-crypt + cryptsetup implementation
 
+from __future__ import print_function
 import subprocess
 import os
 import os.path
@@ -376,7 +377,7 @@ def test_once(config, qemu_img=False):
     finally:
         iotests.log("# Delete image")
         delete_image(config)
-        print
+        print()
 
 
 # Obviously we only work with the luks image format
tests/qemu-iotests/165 +2 -1
index 2936929627..88f62d3c6d 100755
@@ -18,6 +18,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
+from __future__ import print_function
 import os
 import re
 import iotests
@@ -85,7 +86,7 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase):
         log = re.sub(r'^\[I \d+\.\d+\] OPENED\n', '', log)
         log = re.sub(r'\[I \+\d+\.\d+\] CLOSED\n?$', '', log)
         if log:
-            print log
+            print(log)
 
         self.vm = self.mkVm()
         self.vm.launch()
tests/qemu-iotests/iotests.py +3 -2
index fdbdd8b300..fd8f79fef9 100644
@@ -1,3 +1,4 @@
+from __future__ import print_function
 # Common utilities and Python wrappers for qemu-iotests
 #
 # Copyright (C) 2012 IBM Corp.
@@ -239,7 +240,7 @@ def filter_img_info(output, filename):
 def log(msg, filters=[]):
     for flt in filters:
         msg = flt(msg)
-    print msg
+    print(msg)
 
 class Timeout:
     def __init__(self, seconds, errmsg = "Timeout"):
@@ -599,7 +600,7 @@ def notrun(reason):
     seq = os.path.basename(sys.argv[0])
 
     open('%s/%s.notrun' % (output_dir, seq), 'wb').write(reason + '\n')
-    print '%s not run: %s' % (seq, reason)
+    print('%s not run: %s' % (seq, reason))
     sys.exit(0)
 
 def verify_image_format(supported_fmts=[], unsupported_fmts=[]):
tests/qemu-iotests/nbd-fault-injector.py +4 -3
index 8a04d979aa..f9193c0fae 100755
@@ -43,6 +43,7 @@
 # This work is licensed under the terms of the GNU GPL, version 2 or later.
 # See the COPYING file in the top-level directory.
 
+from __future__ import print_function
 import sys
 import socket
 import struct
@@ -110,7 +111,7 @@ class FaultInjectionSocket(object):
         for rule in self.rules:
             if rule.match(event, io):
                 if rule.when == 0 or bufsize is None:
-                    print 'Closing connection on rule match %s' % rule.name
+                    print('Closing connection on rule match %s' % rule.name)
                     sys.exit(0)
                 if rule.when != -1:
                     return rule.when
@@ -182,7 +183,7 @@ def handle_connection(conn, use_export):
         elif req.type == NBD_CMD_DISC:
             break
         else:
-            print 'unrecognized command type %#02x' % req.type
+            print('unrecognized command type %#02x' % req.type)
             break
     conn.close()
 
@@ -242,7 +243,7 @@ def open_socket(path):
         sock = socket.socket(socket.AF_UNIX)
         sock.bind(path)
     sock.listen(0)
-    print 'Listening on %s' % path
+    print('Listening on %s' % path)
     sys.stdout.flush() # another process may be waiting, show message now
     return sock
 
tests/qemu-iotests/qcow2.py +20 -19
index 9cc4cf7d08..b95a837759 100755
@@ -1,5 +1,6 @@
 #!/usr/bin/env python
 
+from __future__ import print_function
 import sys
 import struct
 import string
@@ -129,8 +130,8 @@ class QcowHeader:
 
     def dump(self):
         for f in QcowHeader.fields:
-            print "%-25s" % f[2], f[1] % self.__dict__[f[2]]
-        print ""
+            print("%-25s" % f[2], f[1] % self.__dict__[f[2]])
+        print("")
 
     def dump_extensions(self):
         for ex in self.extensions:
@@ -141,11 +142,11 @@ class QcowHeader:
             else:
                 data = "<binary>"
 
-            print "Header extension:"
-            print "%-25s %#x" % ("magic", ex.magic)
-            print "%-25s %d" % ("length", ex.length)
-            print "%-25s %s" % ("data", data)
-            print ""
+            print("Header extension:")
+            print("%-25s %#x" % ("magic", ex.magic))
+            print("%-25s %d" % ("length", ex.length))
+            print("%-25s %s" % ("data", data))
+            print("")
 
 
 def cmd_dump_header(fd):
@@ -157,12 +158,12 @@ def cmd_set_header(fd, name, value):
     try:
         value = int(value, 0)
     except:
-        print "'%s' is not a valid number" % value
+        print("'%s' is not a valid number" % value)
         sys.exit(1)
 
     fields = (field[2] for field in QcowHeader.fields)
     if not name in fields:
-        print "'%s' is not a known header field" % name
+        print("'%s' is not a known header field" % name)
         sys.exit(1)
 
     h = QcowHeader(fd)
@@ -173,7 +174,7 @@ def cmd_add_header_ext(fd, magic, data):
     try:
         magic = int(magic, 0)
     except:
-        print "'%s' is not a valid magic number" % magic
+        print("'%s' is not a valid magic number" % magic)
         sys.exit(1)
 
     h = QcowHeader(fd)
@@ -188,7 +189,7 @@ def cmd_del_header_ext(fd, magic):
     try:
         magic = int(magic, 0)
     except:
-        print "'%s' is not a valid magic number" % magic
+        print("'%s' is not a valid magic number" % magic)
         sys.exit(1)
 
     h = QcowHeader(fd)
@@ -200,7 +201,7 @@ def cmd_del_header_ext(fd, magic):
             h.extensions.remove(ex)
 
     if not found:
-        print "No such header extension"
+        print("No such header extension")
         return
 
     h.update(fd)
@@ -211,7 +212,7 @@ def cmd_set_feature_bit(fd, group, bit):
         if bit < 0 or bit >= 64:
             raise ValueError
     except:
-        print "'%s' is not a valid bit number in range [0, 64)" % bit
+        print("'%s' is not a valid bit number in range [0, 64)" % bit)
         sys.exit(1)
 
     h = QcowHeader(fd)
@@ -222,7 +223,7 @@ def cmd_set_feature_bit(fd, group, bit):
     elif group == 'autoclear':
         h.autoclear_features |= 1 << bit
     else:
-        print "'%s' is not a valid group, try 'incompatible', 'compatible', or 'autoclear'" % group
+        print("'%s' is not a valid group, try 'incompatible', 'compatible', or 'autoclear'" % group)
         sys.exit(1)
 
     h.update(fd)
@@ -248,16 +249,16 @@ def main(filename, cmd, args):
             else:
                 handler(fd, *args)
                 return
-        print "Unknown command '%s'" % cmd
+        print("Unknown command '%s'" % cmd)
     finally:
         fd.close()
 
 def usage():
-    print "Usage: %s <file> <cmd> [<arg>, ...]" % sys.argv[0]
-    print ""
-    print "Supported commands:"
+    print("Usage: %s <file> <cmd> [<arg>, ...]" % sys.argv[0])
+    print("")
+    print("Supported commands:")
     for name, handler, num_args, desc in cmds:
-        print "    %-20s - %s" % (name, desc)
+        print("    %-20s - %s" % (name, desc))
 
 if __name__ == '__main__':
     if len(sys.argv) < 3:
tests/qemu-iotests/qed.py +9 -8
index 748068d7fe..ea469b9c48 100755
@@ -10,6 +10,7 @@
 # This work is licensed under the terms of the GNU GPL, version 2 or later.
 # See the COPYING file in the top-level directory.
 
+from __future__ import print_function
 import sys
 import struct
 import random
@@ -108,12 +109,12 @@ def corrupt_table_invalidate(qed, table):
 def cmd_show(qed, *args):
     '''show [header|l1|l2 <offset>]- Show header or l1/l2 tables'''
     if not args or args[0] == 'header':
-        print qed.header
+        print(qed.header)
     elif args[0] == 'l1':
-        print qed.l1_table
+        print(qed.l1_table)
     elif len(args) == 2 and args[0] == 'l2':
         offset = int(args[1])
-        print qed.read_table(offset)
+        print(qed.read_table(offset))
     else:
         err('unrecognized sub-command')
 
@@ -146,7 +147,7 @@ def cmd_invalidate(qed, table_level):
 def cmd_need_check(qed, *args):
     '''need-check [on|off] - Test, set, or clear the QED_F_NEED_CHECK header bit'''
     if not args:
-        print bool(qed.header['features'] & QED_F_NEED_CHECK)
+        print(bool(qed.header['features'] & QED_F_NEED_CHECK))
         return
 
     if args[0] == 'on':
@@ -208,11 +209,11 @@ def cmd_copy_metadata(qed, outfile):
     out.close()
 
 def usage():
-    print 'Usage: %s <file> <cmd> [<arg>, ...]' % sys.argv[0]
-    print
-    print 'Supported commands:'
+    print('Usage: %s <file> <cmd> [<arg>, ...]' % sys.argv[0])
+    print()
+    print('Supported commands:')
     for cmd in sorted(x for x in globals() if x.startswith('cmd_')):
-        print globals()[cmd].__doc__
+        print(globals()[cmd].__doc__)
     sys.exit(1)
 
 def main():
tests/vm/basevm.py +2 -1
index 3a2d508c35..3643117816 100755
@@ -11,6 +11,7 @@
 # the COPYING file in the top-level directory.
 #
 
+from __future__ import print_function
 import os
 import sys
 import logging
@@ -222,7 +223,7 @@ def main(vmcls):
     try:
         args, argv = parse_args(vmcls.name)
         if not argv and not args.build_qemu and not args.build_image:
-            print "Nothing to do?"
+            print("Nothing to do?")
             return 1
         logging.basicConfig(level=(logging.DEBUG if args.debug
                                    else logging.WARN))
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
#2 lore raw

PATCH 1/1 fixup! python: futurize -f libfuturize.fixes.fix_print_with_import

Quoted 14 lines · Eduardo Habkost

Change all Python code to use print as a function.

This is necessary for Python 3 compatibility.

Done using:

  $ py=$( (g grep -l -E '^#!.*python';find -name '*.py' -printf '%P\n';) | \
    sort -u | grep -v README.sh4)
  $ futurize -w -f libfuturize.fixes.fix_print_with_import $py

---

[...]

Quoted 1 line
 tests/docker/docker.py                   | 11 +--

[...]

This patch needs an update:

---
 tests/docker/docker.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
tests/docker/docker.py +3 -3
index a18cfcbe94..306e14cf69 100755
@@ -400,11 +400,11 @@ class ProbeCommand(SubCommand):
         try:
             docker = Docker()
             if docker._command[0] == "docker":
-                print "yes"
+                print("yes")
             elif docker._command[0] == "sudo":
-                print "sudo"
+                print("sudo")
         except Exception:
-            print "no"
+            print("no")
 
         return
 
Signature · 4 lines
2.18.0.rc1.1.g3f1ff2140

-- 
Eduardo
Reviewed-by on v1 1/1
#3 lore raw

Re: [Qemu-devel] [PATCH] fixup! python: futurize -f libfuturize.fixes.fix_print_with_import

Quoted 17 lines · Eduardo Habkost
Quoted 14 lines · Eduardo Habkost

Change all Python code to use print as a function.

This is necessary for Python 3 compatibility.

Done using:

  $ py=$( (g grep -l -E '^#!.*python';find -name '*.py' -printf '%P\n';) | \
    sort -u | grep -v README.sh4)
  $ futurize -w -f libfuturize.fixes.fix_print_with_import $py

---

[...]

Quoted 1 line
 tests/docker/docker.py                   | 11 +--
Quoted 8 lines

[...]

This patch needs an update:

---
 tests/docker/docker.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
#4 lore raw

PATCH v2 2/10 python: futurize -f libfuturize.fixes.fix_absolute_import

In reply to Eduardo Habkost

Make implicit relative imports explicit and add "from __future__ import absolute_import" at the top of each relevant module.

This is necessary for Python 3 compatibility.

Done using:

  $ py=$( (g grep -l -E '^#!.*python';find -name '*.py' -printf '%P\n';) | \
    sort -u | grep -v README.sh4)
  $ futurize -w -f libfuturize.fixes.fix_absolute_import $py

---
Changes v1 -> v2:
* Moved "from __future__ import" line after copyright header

---
 scripts/qmp/qemu-ga-client           | 3 ++-
 scripts/qmp/qmp                      | 3 ++-
 scripts/qmp/qmp-shell                | 3 ++-
 scripts/qmp/qom-fuse                 | 3 ++-
 scripts/qmp/qom-get                  | 3 ++-
 scripts/qmp/qom-list                 | 3 ++-
 scripts/qmp/qom-set                  | 3 ++-
 scripts/qmp/qom-tree                 | 3 ++-
 tests/image-fuzzer/qcow2/__init__.py | 3 ++-
 tests/image-fuzzer/qcow2/layout.py   | 3 ++-
 10 files changed, 20 insertions(+), 10 deletions(-)
scripts/qmp/qemu-ga-client +2 -1
index 8510814683..6045fcd3f2 100755
@@ -37,10 +37,11 @@
 #
 
 from __future__ import print_function
+from __future__ import absolute_import
 import base64
 import random
 
-import qmp
+from . import qmp
 
 
 class QemuGuestAgent(qmp.QEMUMonitorProtocol):
scripts/qmp/qmp +2 -1
index 16d3bdb6fe..4d2be4e98a 100755
@@ -11,8 +11,9 @@
 # See the COPYING file in the top-level directory.
 
 from __future__ import print_function
+from __future__ import absolute_import
 import sys, os
-from qmp import QEMUMonitorProtocol
+from .qmp import QEMUMonitorProtocol
 
 def print_response(rsp, prefix=[]):
     if type(rsp) == list:
scripts/qmp/qmp-shell +2 -1
index b1cc7e2271..38c99d8f72 100755
@@ -66,7 +66,8 @@
 # sent to QEMU, which is useful for debugging and documentation generation.
 
 from __future__ import print_function
-import qmp
+from __future__ import absolute_import
+from . import qmp
 import json
 import ast
 import readline
scripts/qmp/qom-fuse +2 -1
index 5c6754aa63..b75aa72767 100755
@@ -11,11 +11,12 @@
 # the COPYING file in the top-level directory.
 ##
 
+from __future__ import absolute_import
 import fuse, stat
 from fuse import Fuse
 import os, posix
 from errno import *
-from qmp import QEMUMonitorProtocol
+from .qmp import QEMUMonitorProtocol
 
 fuse.fuse_python_api = (0, 2)
 
scripts/qmp/qom-get +2 -1
index 291c8bfbc2..6313f27e8e 100755
@@ -12,9 +12,10 @@
 ##
 
 from __future__ import print_function
+from __future__ import absolute_import
 import sys
 import os
-from qmp import QEMUMonitorProtocol
+from .qmp import QEMUMonitorProtocol
 
 cmd, args = sys.argv[0], sys.argv[1:]
 socket_path = None
scripts/qmp/qom-list +2 -1
index cd907bb81f..80b0a3d1be 100755
@@ -12,9 +12,10 @@
 ##
 
 from __future__ import print_function
+from __future__ import absolute_import
 import sys
 import os
-from qmp import QEMUMonitorProtocol
+from .qmp import QEMUMonitorProtocol
 
 cmd, args = sys.argv[0], sys.argv[1:]
 socket_path = None
scripts/qmp/qom-set +2 -1
index fbe4b3e471..cbffb65880 100755
@@ -12,9 +12,10 @@
 ##
 
 from __future__ import print_function
+from __future__ import absolute_import
 import sys
 import os
-from qmp import QEMUMonitorProtocol
+from .qmp import QEMUMonitorProtocol
 
 cmd, args = sys.argv[0], sys.argv[1:]
 socket_path = None
scripts/qmp/qom-tree +2 -1
index 0ffd1ff1de..ad4be233e6 100755
@@ -14,9 +14,10 @@
 ##
 
 from __future__ import print_function
+from __future__ import absolute_import
 import sys
 import os
-from qmp import QEMUMonitorProtocol
+from .qmp import QEMUMonitorProtocol
 
 cmd, args = sys.argv[0], sys.argv[1:]
 socket_path = None
tests/image-fuzzer/qcow2/__init__.py +2 -1
index e2ebe19311..09ef59821b 100644
@@ -1 +1,2 @@
-from layout import create_image
+from __future__ import absolute_import
+from .layout import create_image
tests/image-fuzzer/qcow2/layout.py +2 -1
index 63e801f4e8..675877da96 100644
@@ -16,9 +16,10 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 
+from __future__ import absolute_import
 import random
 import struct
-import fuzz
+from . import fuzz
 from math import ceil
 from os import urandom
 from itertools import chain
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
Reviewed-by on v2 2/10
#5 lore raw

Re: [Qemu-devel] [PATCH v2 02/10] python: futurize -f libfuturize.fixes.fix_absolute_import

Quoted 15 lines · Eduardo Habkost

Make implicit relative imports explicit and add "from __future__ import absolute_import" at the top of each relevant module.

This is necessary for Python 3 compatibility.

Done using:

  $ py=$( (g grep -l -E '^#!.*python';find -name '*.py' -printf '%P\n';) | \
    sort -u | grep -v README.sh4)
  $ futurize -w -f libfuturize.fixes.fix_absolute_import $py

---
Changes v1 -> v2:
* Moved "from __future__ import" line after copyright header

Quoted 12 lines
---
 scripts/qmp/qemu-ga-client           | 3 ++-
 scripts/qmp/qmp                      | 3 ++-
 scripts/qmp/qmp-shell                | 3 ++-
 scripts/qmp/qom-fuse                 | 3 ++-
 scripts/qmp/qom-get                  | 3 ++-
 scripts/qmp/qom-list                 | 3 ++-
 scripts/qmp/qom-set                  | 3 ++-
 scripts/qmp/qom-tree                 | 3 ++-
 tests/image-fuzzer/qcow2/__init__.py | 3 ++-
 tests/image-fuzzer/qcow2/layout.py   | 3 ++-
 10 files changed, 20 insertions(+), 10 deletions(-)
#6 lore raw

PATCH v2 3/10 python: futurize -f libfuturize.fixes.fix_next_call

In reply to Eduardo Habkost

Change obj.next() calls to next(obj).

This is necessary for Python 3 compatibility.

Done using:

  $ py=$( (g grep -l -E '^#!.*python';find -name '*.py' -printf '%P\n';) | \
    sort -u | grep -v README.sh4)
  $ futurize -w -f libfuturize.fixes.fix_next_call $py
---
 scripts/ordereddict.py            | 4 ++--
 scripts/vmstate-static-checker.py | 4 ++--
 tests/image-fuzzer/runner.py      | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
scripts/ordereddict.py +2 -2
index 2d1d81370b..68ed340b33 100644
@@ -71,9 +71,9 @@ class OrderedDict(dict, DictMixin):
         if not self:
             raise KeyError('dictionary is empty')
         if last:
-            key = reversed(self).next()
+            key = next(reversed(self))
         else:
-            key = iter(self).next()
+            key = next(iter(self))
         value = self.pop(key)
         return key, value
 
scripts/vmstate-static-checker.py +2 -2
index 60d1bf4cda..d3467288dc 100755
@@ -158,7 +158,7 @@ def check_fields(src_fields, dest_fields, desc, sec):
     while True:
         if advance_src:
             try:
-                s_item = s_iter.next()
+                s_item = next(s_iter)
             except StopIteration:
                 if s_iter_list == []:
                     break
@@ -173,7 +173,7 @@ def check_fields(src_fields, dest_fields, desc, sec):
 
         if advance_dest:
             try:
-                d_item = d_iter.next()
+                d_item = next(d_iter)
             except StopIteration:
                 if d_iter_list == []:
                     # We were not in a substruct
tests/image-fuzzer/runner.py +1 -1
index 8de656933e..45e8fca63f 100755
@@ -422,7 +422,7 @@ if __name__ == '__main__':
     test_id = count(1)
     while should_continue(duration, start_time):
         try:
-            run_test(str(test_id.next()), seed, work_dir, run_log, cleanup,
+            run_test(str(next(test_id)), seed, work_dir, run_log, cleanup,
                      log_all, command, config)
         except (KeyboardInterrupt, SystemExit):
             sys.exit(1)
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
#7 lore raw

PATCH v2 4/10 python: futurize -f lib2to3.fixes.fix_has_key

In reply to Eduardo Habkost

Change "dict.has_key(key)" to "key in dict"

This is necessary for Python 3 compatibility.

Done using:

  $ py=$( (g grep -l -E '^#!.*python';find -name '*.py' -printf '%P\n';) | \
    sort -u | grep -v README.sh4)
  $ futurize -w -f lib2to3.fixes.fix_has_key $py
---
 scripts/qmp/qmp        | 4 ++--
 scripts/qmp/qmp-shell  | 2 +-
 scripts/qmp/qom-fuse   | 2 +-
 scripts/qmp/qom-get    | 2 +-
 scripts/qmp/qom-list   | 2 +-
 scripts/qmp/qom-set    | 2 +-
 scripts/qmp/qom-tree   | 2 +-
 tests/qemu-iotests/093 | 2 +-
 tests/qemu-iotests/096 | 4 ++--
 tests/qemu-iotests/136 | 2 +-
 10 files changed, 12 insertions(+), 12 deletions(-)
scripts/qmp/qmp +2 -2
index 4d2be4e98a..33a0d6b73a 100755
@@ -36,7 +36,7 @@ def main(args):
     path = None
 
     # Use QMP_PATH if it's set
-    if os.environ.has_key('QMP_PATH'):
+    if 'QMP_PATH' in os.environ:
         path = os.environ['QMP_PATH']
 
     while len(args):
@@ -80,7 +80,7 @@ def main(args):
 
     def do_command(srv, cmd, **kwds):
         rsp = srv.cmd(cmd, kwds)
-        if rsp.has_key('error'):
+        if 'error' in rsp:
             raise Exception(rsp['error']['desc'])
         return rsp['return']
 
scripts/qmp/qmp-shell +1 -1
index 38c99d8f72..26418dab95 100755
@@ -134,7 +134,7 @@ class QMPShell(qmp.QEMUMonitorProtocol):
 
     def _fill_completion(self):
         cmds = self.cmd('query-commands')
-        if cmds.has_key('error'):
+        if 'error' in cmds:
             return
         for cmd in cmds['return']:
             self._completer.append(cmd['name'])
scripts/qmp/qom-fuse +1 -1
index b75aa72767..b00cb0a0af 100755
@@ -29,7 +29,7 @@ class QOMFS(Fuse):
         self.ino_count = 1
 
     def get_ino(self, path):
-        if self.ino_map.has_key(path):
+        if path in self.ino_map:
             return self.ino_map[path]
         self.ino_map[path] = self.ino_count
         self.ino_count += 1
scripts/qmp/qom-get +1 -1
index 6313f27e8e..a3f5d7660e 100755
@@ -45,7 +45,7 @@ if len(args) > 0:
         args = args[2:]
 
 if not socket_path:
-    if os.environ.has_key('QMP_SOCKET'):
+    if 'QMP_SOCKET' in os.environ:
         socket_path = os.environ['QMP_SOCKET']
     else:
         usage_error("no QMP socket path or address given");
scripts/qmp/qom-list +1 -1
index 80b0a3d1be..2ba25e1792 100755
@@ -45,7 +45,7 @@ if len(args) > 0:
         args = args[2:]
 
 if not socket_path:
-    if os.environ.has_key('QMP_SOCKET'):
+    if 'QMP_SOCKET' in os.environ:
         socket_path = os.environ['QMP_SOCKET']
     else:
         usage_error("no QMP socket path or address given");
scripts/qmp/qom-set +1 -1
index cbffb65880..0352668812 100755
@@ -46,7 +46,7 @@ if len(args) > 0:
         args = args[2:]
 
 if not socket_path:
-    if os.environ.has_key('QMP_SOCKET'):
+    if 'QMP_SOCKET' in os.environ:
         socket_path = os.environ['QMP_SOCKET']
     else:
         usage_error("no QMP socket path or address given");
scripts/qmp/qom-tree +1 -1
index ad4be233e6..32e708a13e 100755
@@ -47,7 +47,7 @@ if len(args) > 0:
         args = args[2:]
 
 if not socket_path:
-    if os.environ.has_key('QMP_SOCKET'):
+    if 'QMP_SOCKET' in os.environ:
         socket_path = os.environ['QMP_SOCKET']
     else:
         usage_error("no QMP socket path or address given");
tests/qemu-iotests/093 +1 -1
index c3404a3171..68e344f8c1 100755
@@ -237,7 +237,7 @@ class ThrottleTestGroupNames(iotests.QMPTestCase):
                 if name:
                     self.assertEqual(info["group"], name)
                 else:
-                    self.assertFalse(info.has_key('group'))
+                    self.assertFalse('group' in info)
                 return
 
         raise Exception("No group information found for '%s'" % device)
tests/qemu-iotests/096 +2 -2
index aeeb3753cf..a69439602d 100755
@@ -53,9 +53,9 @@ class TestLiveSnapshot(iotests.QMPTestCase):
                 self.assertEqual(r['iops'], self.iops)
                 self.assertEqual(r['iops_size'], self.iops_size)
             else:
-                self.assertFalse(r.has_key('group'))
+                self.assertFalse('group' in r)
                 self.assertEqual(r['iops'], 0)
-                self.assertFalse(r.has_key('iops_size'))
+                self.assertFalse('iops_size' in r)
 
     def testSnapshot(self):
         self.checkConfig('base')
tests/qemu-iotests/136 +1 -1
index 88b97ea7c6..a154d8ef9d 100755
@@ -203,7 +203,7 @@ sector = "%d"
         if (self.accounted_ops(read = True, write = True, flush = True) != 0):
             self.assertLess(0, stats['idle_time_ns'])
         else:
-            self.assertFalse(stats.has_key('idle_time_ns'))
+            self.assertFalse('idle_time_ns' in stats)
 
         # This test does not alter these, so they must be all 0
         self.assertEqual(0, stats['rd_merged'])
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
#8 lore raw

PATCH v2 5/10 python: futurize -f lib2to3.fixes.fix_standarderror

In reply to Eduardo Habkost

Rename StandardError to Exception.

This is necessary for Python 3 compatibility.

Done using:

  $ py=$( (g grep -l -E '^#!.*python';find -name '*.py' -printf '%P\n';) | \
    sort -u | grep -v README.sh4)
  $ futurize -w -f lib2to3.fixes.fix_standarderror $py
---
 scripts/qmp/qemu-ga-client | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/qmp/qemu-ga-client +3 -3
index 6045fcd3f2..976e69e05f 100755
@@ -137,7 +137,7 @@ class QemuGuestAgentClient:
 
     def fsfreeze(self, cmd):
         if cmd not in ['status', 'freeze', 'thaw']:
-            raise StandardError('Invalid command: ' + cmd)
+            raise Exception('Invalid command: ' + cmd)
 
         return getattr(self.qga, 'fsfreeze' + '_' + cmd)()
 
@@ -146,7 +146,7 @@ class QemuGuestAgentClient:
 
     def suspend(self, mode):
         if mode not in ['disk', 'ram', 'hybrid']:
-            raise StandardError('Invalid mode: ' + mode)
+            raise Exception('Invalid mode: ' + mode)
 
         try:
             getattr(self.qga, 'suspend' + '_' + mode)()
@@ -157,7 +157,7 @@ class QemuGuestAgentClient:
 
     def shutdown(self, mode='powerdown'):
         if mode not in ['powerdown', 'halt', 'reboot']:
-            raise StandardError('Invalid mode: ' + mode)
+            raise Exception('Invalid mode: ' + mode)
 
         try:
             self.qga.shutdown(mode=mode)
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
#9 lore raw

PATCH v2 6/10 python: futurize -f lib2to3.fixes.fix_reduce

In reply to Eduardo Habkost

Handle the move of reduce() to functools.reduce().

This is necessary for Python 3 compatibility.

Done using:

  $ py=$( (g grep -l -E '^#!.*python';find -name '*.py' -printf '%P\n';) | \
    sort -u | grep -v README.sh4)
  $ futurize -w -f lib2to3.fixes.fix_reduce $py
---
 tests/image-fuzzer/qcow2/fuzz.py | 1 +
 1 file changed, 1 insertion(+)
tests/image-fuzzer/qcow2/fuzz.py +1 -0
index 20eba6bc1b..abc4f0635d 100644
@@ -17,6 +17,7 @@
 #
 
 import random
+from functools import reduce
 
 UINT8 = 0xff
 UINT16 = 0xffff
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
#10 lore raw

PATCH v2 7/10 python: futurize -f lib2to3.fixes.fix_tuple_params

In reply to Eduardo Habkost

Remove implicit tuple parameter unpacking.

This is necessary for Python 3 compatibility.

Done using:

  $ py=$( (g grep -l -E '^#!.*python';find -name '*.py' -printf '%P\n';) | \
    sort -u | grep -v README.sh4)
  $ futurize -w -f lib2to3.fixes.fix_tuple_params $py
---
 scripts/analyse-locks-simpletrace.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/analyse-locks-simpletrace.py +1 -1
index 352bc9c22d..30090bdfff 100755
@@ -78,7 +78,7 @@ if __name__ == '__main__':
 
     # Now dump the individual lock stats
     for key, val in sorted(analyser.mutex_records.iteritems(),
-                           key=lambda (k,v): v["locks"]):
+                           key=lambda k_v: k_v[1]["locks"]):
         print ("Lock: %#x locks: %d, locked: %d, unlocked: %d" %
                (key, val["locks"], val["locked"], val["unlocked"]))
 
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
#11 lore raw

PATCH v2 8/10 python: futurize -f lib2to3.fixes.fix_renames

In reply to Eduardo Habkost

Change sys.maxint to sys.maxsize.

This is necessary for Python 3 compatibility.

Done using:

  $ py=$( (g grep -l -E '^#!.*python';find -name '*.py' -printf '%P\n';) | \
    sort -u | grep -v README.sh4)
  $ futurize -w -f lib2to3.fixes.fix_renames $py
---
 tests/image-fuzzer/runner.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/image-fuzzer/runner.py +1 -1
index 45e8fca63f..95d84f38f3 100755
@@ -128,7 +128,7 @@ class TestEnv(object):
         if seed is not None:
             self.seed = seed
         else:
-            self.seed = str(random.randint(0, sys.maxint))
+            self.seed = str(random.randint(0, sys.maxsize))
         random.seed(self.seed)
 
         self.init_path = os.getcwd()
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
#12 lore raw

PATCH v2 9/10 python: futurize -f lib2to3.fixes.fix_except

In reply to Eduardo Habkost

Convert "except X, T" to "except X as T".

This is necessary for Python 3 compatibility.

Done using:

  $ py=$( (g grep -l -E '^#!.*python';find -name '*.py' -printf '%P\n';) | \
    sort -u | grep -v README.sh4)
  $ futurize -w -f lib2to3.fixes.fix_except $py
---
 scripts/simpletrace.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/simpletrace.py +1 -1
index 2658b5cc7c..d4a50a1e2b 100755
@@ -45,7 +45,7 @@ def get_record(edict, idtoname, rechdr, fobj):
         rec = (name, rechdr[1], rechdr[3])
         try:
             event = edict[name]
-        except KeyError, e:
+        except KeyError as e:
             import sys
             sys.stderr.write('%s event is logged but is not declared ' \
                              'in the trace events file, try using ' \
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
#13 lore raw

PATCH v2 10/10 python: futurize -f lib2to3.fixes.fix_numliterals

In reply to Eduardo Habkost

Convert octal literals into the new syntax.

This is necessary for Python 3 compatibility.

Done using:

  $ py=$( (g grep -l -E '^#!.*python';find -name '*.py' -printf '%P\n';) | \
    sort -u | grep -v README.sh4)
  $ futurize -w -f lib2to3.fixes.fix_numliterals $py
---
 scripts/qmp/qom-fuse   |  6 +++---
 tests/qemu-iotests/118 | 24 ++++++++++++------------
 2 files changed, 15 insertions(+), 15 deletions(-)
scripts/qmp/qom-fuse +3 -3
index b00cb0a0af..e524e798fc 100755
@@ -90,7 +90,7 @@ class QOMFS(Fuse):
 
     def getattr(self, path):
         if self.is_link(path):
-            value = posix.stat_result((0755 | stat.S_IFLNK,
+            value = posix.stat_result((0o755 | stat.S_IFLNK,
                                        self.get_ino(path),
                                        0,
                                        2,
@@ -101,7 +101,7 @@ class QOMFS(Fuse):
                                        0,
                                        0))
         elif self.is_object(path):
-            value = posix.stat_result((0755 | stat.S_IFDIR,
+            value = posix.stat_result((0o755 | stat.S_IFDIR,
                                        self.get_ino(path),
                                        0,
                                        2,
@@ -112,7 +112,7 @@ class QOMFS(Fuse):
                                        0,
                                        0))
         elif self.is_property(path):
-            value = posix.stat_result((0644 | stat.S_IFREG,
+            value = posix.stat_result((0o644 | stat.S_IFREG,
                                        self.get_ino(path),
                                        0,
                                        1,
tests/qemu-iotests/118 +12 -12
index a0469b570e..ff3b2ae3e7 100755
@@ -390,14 +390,14 @@ class TestChangeReadOnly(ChangeBaseClass):
 
     def tearDown(self):
         self.vm.shutdown()
-        os.chmod(old_img, 0666)
-        os.chmod(new_img, 0666)
+        os.chmod(old_img, 0o666)
+        os.chmod(new_img, 0o666)
         os.remove(old_img)
         os.remove(new_img)
 
     def test_ro_ro_retain(self):
-        os.chmod(old_img, 0444)
-        os.chmod(new_img, 0444)
+        os.chmod(old_img, 0o444)
+        os.chmod(new_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk,read-only=on', 'none')
         self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
         self.vm.launch()
@@ -417,7 +417,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
 
     def test_ro_rw_retain(self):
-        os.chmod(old_img, 0444)
+        os.chmod(old_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk,read-only=on', 'none')
         self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
         self.vm.launch()
@@ -437,7 +437,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
 
     def test_rw_ro_retain(self):
-        os.chmod(new_img, 0444)
+        os.chmod(new_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk', 'none')
         self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
         self.vm.launch()
@@ -459,7 +459,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
 
     def test_ro_rw(self):
-        os.chmod(old_img, 0444)
+        os.chmod(old_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk,read-only=on', 'none')
         self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
         self.vm.launch()
@@ -480,7 +480,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
 
     def test_rw_ro(self):
-        os.chmod(new_img, 0444)
+        os.chmod(new_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk', 'none')
         self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
         self.vm.launch()
@@ -521,7 +521,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
 
     def test_make_ro_rw(self):
-        os.chmod(new_img, 0444)
+        os.chmod(new_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk', 'none')
         self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
         self.vm.launch()
@@ -542,7 +542,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
 
     def test_make_rw_ro_by_retain(self):
-        os.chmod(old_img, 0444)
+        os.chmod(old_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk,read-only=on', 'none')
         self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
         self.vm.launch()
@@ -562,7 +562,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', new_img)
 
     def test_make_ro_rw_by_retain(self):
-        os.chmod(new_img, 0444)
+        os.chmod(new_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk', 'none')
         self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
         self.vm.launch()
@@ -582,7 +582,7 @@ class TestChangeReadOnly(ChangeBaseClass):
         self.assert_qmp(result, 'return[0]/inserted/image/filename', old_img)
 
     def test_rw_ro_cycle(self):
-        os.chmod(new_img, 0444)
+        os.chmod(new_img, 0o444)
         self.vm.add_drive(old_img, 'media=disk', 'none')
         self.vm.add_device('floppy,drive=drive0,id=%s' % self.device_name)
         self.vm.launch()
Signature · 1 line
2.18.0.rc1.1.g3f1ff2140
#14 lore raw
In reply to Eduardo Habkost
This series failed docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

Hi,

This series failed docker-mingw@fedora build test. Please find the testing commands and their output below. If you have Docker installed, you can probably reproduce it locally.

Type: series
Message-id: [email protected]
Subject: [Qemu-devel] [PATCH v2 00/10] python: futurize --stage1 (Python 3 compatibility)

=== TEST SCRIPT BEGIN ===
#!/bin/bash
set -e
git submodule update --init dtc
# Let docker tests dump environment info
export SHOW_ENV=1
export J=8
time make docker-test-mingw@fedora
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
Switched to a new branch 'test'
034a17b732 python: futurize -f lib2to3.fixes.fix_numliterals 24815c6337 python: futurize -f lib2to3.fixes.fix_except 84c2eb4a4a python: futurize -f lib2to3.fixes.fix_renames 8e21c5b4fd python: futurize -f lib2to3.fixes.fix_tuple_params 8314382c8c python: futurize -f lib2to3.fixes.fix_reduce db6bd54016 python: futurize -f lib2to3.fixes.fix_standarderror 26518cce56 python: futurize -f lib2to3.fixes.fix_has_key 710ff909f0 python: futurize -f libfuturize.fixes.fix_next_call 332ca44612 python: futurize -f libfuturize.fixes.fix_absolute_import ebdf9a3fe6 python: futurize -f libfuturize.fixes.fix_print_with_import

=== OUTPUT BEGIN ===
Submodule 'dtc' (git://git.qemu-project.org/dtc.git) registered for path 'dtc' Cloning into '/var/tmp/patchew-tester-tmp-difi82ih/src/dtc'... Submodule path 'dtc': checked out 'e54388015af1fb4bf04d0bca99caba1074d9cc42'
BUILD fedora
File "./tests/docker/docker.py", line 403

    print "yes"
              ^

SyntaxError: invalid syntax
make: *** [tests/docker/Makefile.include:38: docker-image-fedora] Error 1

real 0m0.560s
user 0m0.159s
sys 0m0.175s
=== OUTPUT END ===

Test command exited with code: 2

---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]

#15 lore raw
In reply to Eduardo Habkost
This series seems to have some coding style problems. See output below for more information:

Hi,

This series seems to have some coding style problems. See output below for more information:

Type: series
Message-id: [email protected]
Subject: [Qemu-devel] [PATCH v2 00/10] python: futurize --stage1 (Python 3 compatibility)

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram

commits="$(git log --format=%H --reverse $BASE..)" for c in $commits; do

    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))

done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
034a17b732 python: futurize -f lib2to3.fixes.fix_numliterals 24815c6337 python: futurize -f lib2to3.fixes.fix_except 84c2eb4a4a python: futurize -f lib2to3.fixes.fix_renames 8e21c5b4fd python: futurize -f lib2to3.fixes.fix_tuple_params 8314382c8c python: futurize -f lib2to3.fixes.fix_reduce db6bd54016 python: futurize -f lib2to3.fixes.fix_standarderror 26518cce56 python: futurize -f lib2to3.fixes.fix_has_key 710ff909f0 python: futurize -f libfuturize.fixes.fix_next_call 332ca44612 python: futurize -f libfuturize.fixes.fix_absolute_import ebdf9a3fe6 python: futurize -f libfuturize.fixes.fix_print_with_import

=== OUTPUT BEGIN ===
Checking PATCH 1/10: python: futurize -f libfuturize.fixes.fix_print_with_import...
ERROR: line over 90 characters
#42: FILE: scripts/analyse-9p-simpletrace.py:86:
+ print("RERROR (tag =", tag, ", id =", symbol_9p[id], ", err = \"", os.strerror(err), "\")")

ERROR: line over 90 characters
#46: FILE: scripts/analyse-9p-simpletrace.py:89:
+ print("TVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")")

ERROR: line over 90 characters
#50: FILE: scripts/analyse-9p-simpletrace.py:92:
+ print("RVERSION (tag =", tag, ", msize =", msize, ", version =", version, ")")

ERROR: line over 90 characters
#54: FILE: scripts/analyse-9p-simpletrace.py:95:
+ print("TATTACH (tag =", tag, ", fid =", fid, ", afid =", afid, ", uname =", uname, ", aname =", aname, ")")

ERROR: line over 90 characters
#58: FILE: scripts/analyse-9p-simpletrace.py:98:
+ print("RATTACH (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "})")

ERROR: line over 90 characters
#66: FILE: scripts/analyse-9p-simpletrace.py:104:
+ print("RSTAT (tag =", tag, ", mode =", mode, ", atime =", atime, ", mtime =", mtime, ", length =", length, ")")

ERROR: line over 90 characters
#70: FILE: scripts/analyse-9p-simpletrace.py:107:
+ print("TGETATTR (tag =", tag, ", fid =", fid, ", request_mask =", hex(request_mask), ")")

ERROR: line over 90 characters
#74: FILE: scripts/analyse-9p-simpletrace.py:110:
+ print("RGETATTR (tag =", tag, ", result_mask =", hex(result_mask), ", mode =", oct(mode), ", uid =", uid, ", gid =", gid, ")")

ERROR: line over 90 characters
#78: FILE: scripts/analyse-9p-simpletrace.py:113:
+ print("TWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", nwnames =", nwnames, ")")

ERROR: line over 90 characters
#82: FILE: scripts/analyse-9p-simpletrace.py:116:
+ print("RWALK (tag =", tag, ", nwnames =", nwnames, ", qids =", hex(qids), ")")

WARNING: line over 80 characters
#86: FILE: scripts/analyse-9p-simpletrace.py:119:
+ print("TOPEN (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ")")

ERROR: line over 90 characters
#90: FILE: scripts/analyse-9p-simpletrace.py:122:
+ print("ROPEN (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")")

ERROR: line over 90 characters
#94: FILE: scripts/analyse-9p-simpletrace.py:125:
+ print("TLCREATE (tag =", tag, ", dfid =", dfid, ", flags =", oct(flags), ", mode =", oct(mode), ", gid =", gid, ")")

ERROR: line over 90 characters
#98: FILE: scripts/analyse-9p-simpletrace.py:128:
+ print("RLCREATE (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")")

WARNING: line over 80 characters
#102: FILE: scripts/analyse-9p-simpletrace.py:131:
+ print("TFSYNC (tag =", tag, ", fid =", fid, ", datasync =", datasync, ")")

ERROR: line over 90 characters
#110: FILE: scripts/analyse-9p-simpletrace.py:137:
+ print("TREAD (tag =", tag, ", fid =", fid, ", off =", off, ", max_count =", max_count, ")")

WARNING: line over 80 characters
#114: FILE: scripts/analyse-9p-simpletrace.py:140:
+ print("RREAD (tag =", tag, ", count =", count, ", err =", err, ")")

ERROR: line over 90 characters
#118: FILE: scripts/analyse-9p-simpletrace.py:143:
+ print("TREADDIR (tag =", tag, ", fid =", fid, ", offset =", offset, ", max_count =", max_count, ")")

ERROR: line over 90 characters
#122: FILE: scripts/analyse-9p-simpletrace.py:146:
+ print("RREADDIR (tag =", tag, ", count =", count, ", retval =", retval, ")")

ERROR: line over 90 characters
#126: FILE: scripts/analyse-9p-simpletrace.py:149:
+ print("TWRITE (tag =", tag, ", fid =", fid, ", off =", off, ", count =", count, ", cnt =", cnt, ")")

WARNING: line over 80 characters
#130: FILE: scripts/analyse-9p-simpletrace.py:152:
+ print("RWRITE (tag =", tag, ", total =", total, ", err =", err, ")")

ERROR: line over 90 characters
#134: FILE: scripts/analyse-9p-simpletrace.py:155:
+ print("TCREATE (tag =", tag, ", fid =", fid, ", perm =", oct(perm), ", name =", name, ", mode =", oct(mode), ")")

ERROR: line over 90 characters
#138: FILE: scripts/analyse-9p-simpletrace.py:158:
+ print("RCREATE (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, iounit =", iounit, ")")

ERROR: line over 90 characters
#142: FILE: scripts/analyse-9p-simpletrace.py:161:
+ print("TSYMLINK (tag =", tag, ", fid =", fid, ", name =", name, ", symname =", symname, ", gid =", gid, ")")

ERROR: line over 90 characters
#146: FILE: scripts/analyse-9p-simpletrace.py:164:
+ print("RSYMLINK (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "})")

ERROR: line over 90 characters
#154: FILE: scripts/analyse-9p-simpletrace.py:170:
+ print("TLINK (tag =", tag, ", dfid =", dfid, ", oldfid =", oldfid, ", name =", name, ")")

ERROR: line over 90 characters
#162: FILE: scripts/analyse-9p-simpletrace.py:176:
+ print("TWSTAT (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", atime =", atime, "mtime =", mtime, ")")

ERROR: line over 90 characters
#166: FILE: scripts/analyse-9p-simpletrace.py:179:
+ print("TMKNOD (tag =", tag, ", fid =", fid, ", mode =", oct(mode), ", major =", major, ", minor =", minor, ")")

ERROR: line over 90 characters
#170: FILE: scripts/analyse-9p-simpletrace.py:182:
+ print("TLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")")

ERROR: line over 90 characters
#178: FILE: scripts/analyse-9p-simpletrace.py:188:
+ print("TGETLOCK (tag =", tag, ", fid =", fid, "type =", type, ", start =", start, ", length =", length, ")")

ERROR: line over 90 characters
#182: FILE: scripts/analyse-9p-simpletrace.py:191:
+ print("RGETLOCK (tag =", tag, "type =", type, ", start =", start, ", length =", length, ", proc_id =", proc_id, ")")

ERROR: line over 90 characters
#186: FILE: scripts/analyse-9p-simpletrace.py:194:
+ print("TMKDIR (tag =", tag, ", fid =", fid, ", name =", name, ", mode =", mode, ", gid =", gid, ")")

ERROR: line over 90 characters
#190: FILE: scripts/analyse-9p-simpletrace.py:197:
+ print("RMKDIR (tag =", tag, ", qid={type =", type, ", version =", version, ", path =", path, "}, err =", err, ")")

ERROR: line over 90 characters
#194: FILE: scripts/analyse-9p-simpletrace.py:200:
+ print("TXATTRWALK (tag =", tag, ", fid =", fid, ", newfid =", newfid, ", xattr name =", name, ")")

ERROR: line over 90 characters
#202: FILE: scripts/analyse-9p-simpletrace.py:206:
+ print("TXATTRCREATE (tag =", tag, ", fid =", fid, ", name =", name, ", xattrsize =", size, ", flags =", flags, ")")

WARNING: line over 80 characters
#845: FILE: scripts/vmstate-static-checker.py:182:
+ print("expected field \"" + s_item["field"] + "\",", end=' ')

WARNING: line over 80 characters
#901: FILE: scripts/vmstate-static-checker.py:293:
+ print("Section \"" + sec + "\", Description \"" + desc + "\":", end=' ')

WARNING: line over 80 characters
#1009: FILE: scripts/vmstate-static-checker.py:419:
+ print("Section \"" + sec + "\": Entry \"" + entry + "\"", end=' ')

WARNING: line over 80 characters
#1129: FILE: tests/image-fuzzer/runner.py:41:
+ "'--config' and '--command' options are not supported.", file=sys.stderr)

WARNING: line over 80 characters
#1140: FILE: tests/image-fuzzer/runner.py:161:
+ print("Error: The working directory '%s' cannot be used. Reason: %s"\

ERROR: line over 90 characters
#1169: FILE: tests/image-fuzzer/runner.py:359:
+ print("Error: %s\n\nTry 'runner.py --help' for more information" % e, file=sys.stderr)

WARNING: line over 80 characters
#1231: FILE: tests/migration/guestperf/engine.py:121:
+ print("Sleeping %d seconds for initial guest workload run" % self._sleep)

ERROR: line over 90 characters
#1249: FILE: tests/migration/guestperf/engine.py:220:
+ print("Sleeping %d seconds for final guest workload run" % self._sleep)

WARNING: line over 80 characters
#1258: FILE: tests/migration/guestperf/engine.py:231:
+ print("Iter %d: remain %5dMB of %5dMB (total %5dMB @ %5dMb/sec)" % (

ERROR: line over 90 characters
#1270: FILE: tests/migration/guestperf/engine.py:241:
+ print("No completion after %d iterations over RAM" % scenario._max_iters)

ERROR: line over 90 characters
#1286: FILE: tests/migration/guestperf/engine.py:255:
+ print("Switching to post-copy after %d iterations" % scenario._post_copy_iters)

WARNING: line over 80 characters
#1295: FILE: tests/migration/guestperf/engine.py:263:
+ print("Pausing VM after %d iterations" % scenario._pause_iters)

ERROR: line over 90 characters
#1653: FILE: tests/qemu-iotests/qcow2.py:226:
+ print("'%s' is not a valid group, try 'incompatible', 'compatible', or 'autoclear'" % group)

total: 36 errors, 12 warnings, 1481 lines checked

Your patch has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

Checking PATCH 2/10: python: futurize -f libfuturize.fixes.fix_absolute_import... Checking PATCH 3/10: python: futurize -f libfuturize.fixes.fix_next_call... Checking PATCH 4/10: python: futurize -f lib2to3.fixes.fix_has_key... Checking PATCH 5/10: python: futurize -f lib2to3.fixes.fix_standarderror... Checking PATCH 6/10: python: futurize -f lib2to3.fixes.fix_reduce... Checking PATCH 7/10: python: futurize -f lib2to3.fixes.fix_tuple_params... Checking PATCH 8/10: python: futurize -f lib2to3.fixes.fix_renames... Checking PATCH 9/10: python: futurize -f lib2to3.fixes.fix_except... Checking PATCH 10/10: python: futurize -f lib2to3.fixes.fix_numliterals... === OUTPUT END ===

Test command exited with code: 1

---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to [email protected]