[PATCH] vmstate-static-checker: Fix for current python

Dr. David Alan Gilbert (git) posted 1 patch 4 years, 4 months ago
Test asan passed
Test checkpatch passed
Test FreeBSD passed
Test docker-mingw@fedora passed
Test docker-clang@ubuntu passed
Test docker-quick@centos7 passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20191121185303.51685-1-dgilbert@redhat.com
Maintainers: Cleber Rosa <crosa@redhat.com>, Eduardo Habkost <ehabkost@redhat.com>, Juan Quintela <quintela@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>
scripts/vmstate-static-checker.py | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
[PATCH] vmstate-static-checker: Fix for current python
Posted by Dr. David Alan Gilbert (git) 4 years, 4 months ago
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>

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

Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
---
 scripts/vmstate-static-checker.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/scripts/vmstate-static-checker.py b/scripts/vmstate-static-checker.py
index 21dbdccf3e..9f912dd870 100755
--- a/scripts/vmstate-static-checker.py
+++ b/scripts/vmstate-static-checker.py
@@ -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',
-- 
2.23.0


Re: [PATCH-for-4.2?] vmstate-static-checker: Fix for current python
Posted by Philippe Mathieu-Daudé 4 years, 4 months ago
On 11/21/19 7:53 PM, Dr. David Alan Gilbert (git) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> 
> Python 3.7.5 on f31 doesn't seem to like the old type=file syntax
> on argparse.

Looks 4.2 worth to me.

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
>   scripts/vmstate-static-checker.py | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/vmstate-static-checker.py b/scripts/vmstate-static-checker.py
> index 21dbdccf3e..9f912dd870 100755
> --- a/scripts/vmstate-static-checker.py
> +++ b/scripts/vmstate-static-checker.py
> @@ -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',
> 


Re: [PATCH] vmstate-static-checker: Fix for current python
Posted by Cleber Rosa 4 years, 4 months ago

----- Original Message -----
> From: "Dr. David Alan Gilbert (git)" <dgilbert@redhat.com>
> To: qemu-devel@nongnu.org, quintela@redhat.com, ehabkost@redhat.com, crosa@redhat.com
> Sent: Thursday, November 21, 2019 1:53:03 PM
> Subject: [PATCH] vmstate-static-checker: Fix for current python
> 
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> 
> Python 3.7.5 on f31 doesn't seem to like the old type=file syntax
> on argparse.
> 
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> ---
>  scripts/vmstate-static-checker.py | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/scripts/vmstate-static-checker.py
> b/scripts/vmstate-static-checker.py
> index 21dbdccf3e..9f912dd870 100755
> --- a/scripts/vmstate-static-checker.py
> +++ b/scripts/vmstate-static-checker.py
> @@ -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,

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

>                          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',
> --
> 2.23.0
> 
> 
> 

And I agree that this is 4.2 material.

Reviewed-by: Cleber Rosa <crosa@redhat.com>