[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] scripts: Fix undefinited name 'file' error for python3

From: Han Han
Subject: [PATCH] scripts: Fix undefinited name 'file' error for python3
Date: Wed, 13 Nov 2019 21:16:55 +0800

In python3, 'file' is no longer a keyword for file type object. So it
will can error when run the scripts by python3:

$ python3 ./scripts/vmstate-static-checker.py -s 4.0.json -d 4.1.json
Traceback (most recent call last):
  File "./scripts/vmstate-static-checker.py", line 431, in <module>
  File "./scripts/vmstate-static-checker.py", line 378, in main
    parser.add_argument('-s', '--src', type=file, required=True,
NameError: name 'file' is not defined

Replace file type to argparse.FileType('r').

Signed-off-by: Han Han <address@hidden>
 scripts/vmstate-static-checker.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/vmstate-static-checker.py 
index d3467288..14f199a0 100755
--- a/scripts/vmstate-static-checker.py
+++ b/scripts/vmstate-static-checker.py
@@ -375,9 +375,9 @@ def main():
     help_text = "Parse JSON-formatted vmstate dumps from QEMU in files SRC and 
DEST.  Checks whether migration from SRC to DEST QEMU versions would break 
based on the VMSTATE information contained within the JSON outputs.  The JSON 
output is created from a QEMU invocation with the -dump-vmstate parameter and a 
filename argument to it.  Other parameters to QEMU do not matter, except the -M 
(machine type) parameter."
     parser = argparse.ArgumentParser(description=help_text)
-    parser.add_argument('-s', '--src', type=file, required=True,
+    parser.add_argument('-s', '--src', type=argparse.FileType('r'), 
                         help='json dump from src qemu')
-    parser.add_argument('-d', '--dest', type=file, required=True,
+    parser.add_argument('-d', '--dest', type=argparse.FileType('r'), 
                         help='json dump from dest qemu')
     parser.add_argument('--reverse', required=False, default=False,

reply via email to

[Prev in Thread] Current Thread [Next in Thread]