[Libguestfs] [libnbd PATCH 3/2] python: Slice pread_structured buffer from original

Richard W.M. Jones rjones at redhat.com
Wed Jun 1 08:51:44 UTC 2022


On Tue, May 31, 2022 at 07:24:03PM -0500, Eric Blake wrote:
> On Wed, Jun 01, 2022 at 02:20:48AM +0300, Nir Soffer wrote:
> > Does this work?
> > 
> >     PySlice_New(NULL, NULL, NULL);
> >     PySlice_AdjustIndices(length, start, stop, step);
> 
> New in python 3.6.1.  README says we still target python 3.3.

There are two things we could do here.  Either move the baseline up.
Python 3.6.1 was released in March 2017 (5 years ago), and more
importantly is available in RHEL 7 which is the oldest Linux distro we
care about.

Or (harder, not necessarily better) detect the required function in
configure.ac, and add a utility function to hide the difference.

> Worse, look at the signature - it does NOT take a PyObject *, and
> therefore it cannot modify an existing slice object (rather, it is
> for easing the computation of how to turn [-1:-2:2] into a slice
> with positive bounds) - you still have to go through a step that
> converts integers into PyObject* before creating a PySlice object.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
nbdkit - Flexible, fast NBD server with plugins
https://gitlab.com/nbdkit/nbdkit


More information about the Libguestfs mailing list