From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Thomas Huth <thuth@redhat.com>
Cc: qemu-devel@nongnu.org, Peter Xu <peterx@redhat.com>,
Fabiano Rosas <farosas@suse.de>, John Snow <jsnow@redhat.com>,
Amit Shah <amit@kernel.org>,
Eduardo Habkost <eduardo@habkost.net>
Subject: Re: [PATCH] scripts/vmstate-static-checker: Fix deprecation warnings with latest argparse
Date: Thu, 30 Oct 2025 10:01:20 +0000 [thread overview]
Message-ID: <aQM3cNUN1sxyUCJr@redhat.com> (raw)
In-Reply-To: <6b52e145-8732-413f-a3db-6e5abf1eb70b@redhat.com>
On Thu, Oct 30, 2025 at 10:45:32AM +0100, Thomas Huth wrote:
> On 30/10/2025 10.42, Thomas Huth wrote:
> > On 30/10/2025 10.33, Daniel P. Berrangé wrote:
> > > On Thu, Oct 30, 2025 at 10:26:38AM +0100, Thomas Huth wrote:
> > > > From: Thomas Huth <thuth@redhat.com>
> > > >
> > > > The argparse.FileType() type has been deprecated in the latest argparse
> > > > version (e.g. the one from Fedora 43), now causing the test_bad_vmstate
> > > > functional test to fail since there are unexpected strings in the output.
> > > > Change the script to use pathlib.Path instead to fix the test_bad_vmstate
> > > > test and to be prepared for the future when the deprecated FileType gets
> > > > removed completely.
> ...
> > > > @@ -393,10 +394,10 @@ def main():
> > > > help='reverse the direction')
> > > > args = parser.parse_args()
> > > > - src_data = json.load(args.src)
> > > > - dest_data = json.load(args.dest)
> > > > - args.src.close()
> > > > - args.dest.close()
> > > > + with open(args.src, 'r', encoding='utf-8') as src_fh:
> > > > + src_data = json.load(src_fh)
> > > > + with open(args.dest, 'r', encoding='utf-8') as dst_fh:
> > > > + dest_data = json.load(dst_fh)
> > >
> > > This could be
> > >
> > > src_data = json.load(args.src.read_text('utf-8'))
> > > dest_data = json.load(args.dest.read_text('utf-8'))
> >
> > Does not work, looks like the load() function cannot deal with a string:
> >
> > $ scripts/vmstate-static-checker.py -s
> > tests/data/vmstate-static-checker/ dump1.json -d
> > tests/data/vmstate-static-checker/dump2.json
> > Traceback (most recent call last):
> > File "../scripts/vmstate-static-checker.py", line 439, in <module>
> > sys.exit(main())
> > ~~~~^^
> > File "../scripts/vmstate-static-checker.py", line 397, in main
> > src_data = json.load(args.src.read_text('utf-8'))
> > File "/usr/lib64/python3.13/json/__init__.py", line 293, in load
> > return loads(fp.read(),
> > ^^^^^^^
> > AttributeError: 'str' object has no attribute 'read'
>
> Ok, there also seems to be a json.loads() function (with "s" at the end)
> that seems to do the job ... but IMHO it would be better to continue using
> the load() function here to let the json parser decide how to read the file.
ok, I don't mind that much
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
next prev parent reply other threads:[~2025-10-30 10:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-30 9:26 [PATCH] scripts/vmstate-static-checker: Fix deprecation warnings with latest argparse Thomas Huth
2025-10-30 9:33 ` Daniel P. Berrangé
2025-10-30 9:42 ` Thomas Huth
2025-10-30 9:45 ` Thomas Huth
2025-10-30 10:01 ` Daniel P. Berrangé [this message]
2025-10-30 10:08 ` Thomas Huth
2025-10-30 10:00 ` Daniel P. Berrangé
2025-10-30 15:10 ` Peter Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aQM3cNUN1sxyUCJr@redhat.com \
--to=berrange@redhat.com \
--cc=amit@kernel.org \
--cc=eduardo@habkost.net \
--cc=farosas@suse.de \
--cc=jsnow@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.