Skip to contentSkip to conversation

vmstate-static-checker: Fix for current python

PATCH In review Dr. David Alan Gilbert (git) 3 participants 3 messages Nov 21, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vmstate-static-checker: Fix for current python

From: "Dr. David Alan Gilbert" <[email protected]>

Python 3.7.5 on f31 doesn't seem to like the old type=file syntax on argparse.

---
 scripts/vmstate-static-checker.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
scripts/vmstate-static-checker.py +4 -2
index 21dbdccf3e..9f912dd870 100755
@@ -379,9 +379,11 @@ 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'),
+                        required=True,
                         help='json dump from src qemu')
-    parser.add_argument('-d', '--dest', type=file, required=True,
+    parser.add_argument('-d', '--dest', type=argparse.FileType('r'),
+                        required=True,
                         help='json dump from dest qemu')
     parser.add_argument('--reverse', required=False, default=False,
                         action='store_true',
Signature · 1 line
2.23.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Dr. David Alan Gilbert (git)

From: "Dr. David Alan Gilbert" <[email protected]>

Python 3.7.5 on f31 doesn't seem to like the old type=file syntax on argparse.

Looks 4.2 worth to me.

Quoted 24 lines
---
  scripts/vmstate-static-checker.py | 6 ++++--
  1 file changed, 4 insertions(+), 2 deletions(-)
scripts/vmstate-static-checker.py +4 -2
index 21dbdccf3e..9f912dd870 100755
@@ -379,9 +379,11 @@ 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'),
+                        required=True,
                          help='json dump from src qemu')
-    parser.add_argument('-d', '--dest', type=file, required=True,
+    parser.add_argument('-d', '--dest', type=argparse.FileType('r'),
+                        required=True,
                          help='json dump from dest qemu')
      parser.add_argument('--reverse', required=False, default=False,
                          action='store_true',
Reviewed-by on v1 1/1
#2 lore raw
In reply to Dr. David Alan Gilbert (git)

----- Original Message -----

Quoted 23 lines

From: "Dr. David Alan Gilbert (git)" <[email protected]>
To: [email protected], [email protected], [email protected], [email protected]
Sent: Thursday, November 21, 2019 1:53:03 PM
Subject: [PATCH] vmstate-static-checker: Fix for current python

From: "Dr. David Alan Gilbert" <[email protected]>

Python 3.7.5 on f31 doesn't seem to like the old type=file syntax on argparse.

---
 scripts/vmstate-static-checker.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
scripts/vmstate-static-checker.py +0 -0
index 21dbdccf3e..9f912dd870 100755
@@ -379,9 +379,11 @@ 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

scripts/vmstate-static-checker.py def main():

Quoted 10 lines
scripts/vmstate-static-checker.py +2 -1
     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'),
+                        required=True,

Actually, as far back as Python 3.4 (maybe even earlier) file is not a valid built-in function anymore.

Quoted 8 lines

help='json dump from src qemu')

scripts/vmstate-static-checker.py +2 -2
-    parser.add_argument('-d', '--dest', type=file, required=True,
+    parser.add_argument('-d', '--dest', type=argparse.FileType('r'),
+                        required=True,
                         help='json dump from dest qemu')
     parser.add_argument('--reverse', required=False, default=False,
                         action='store_true',
--
Quoted 4 lines

2.23.0

And I agree that this is 4.2 material.