search for: py_buildvalu

Displaying 20 results from an estimated 45 matches for "py_buildvalu".

Did you mean: py_buildvalue
2023 Feb 20
2
[PATCH 1/2] python: Avoid crash if callback parameters cannot be built
On Mon, Feb 20, 2023 at 10:45 AM Laszlo Ersek <lersek at redhat.com> wrote: > > On 2/17/23 17:52, Eric Blake wrote: > > On Thu, Feb 16, 2023 at 03:09:02PM +0100, Laszlo Ersek wrote: > > >> - Py_BuildValue with the "O" format specifier transfers the new list's > >> *sole* reference (= ownership) to the just-built higher-level object "args" > > > > Reference transfer is done with "N", not "O". That would be an > > alternative to...
2023 Feb 20
2
[PATCH 1/2] python: Avoid crash if callback parameters cannot be built
On 2/17/23 17:52, Eric Blake wrote: > On Thu, Feb 16, 2023 at 03:09:02PM +0100, Laszlo Ersek wrote: >> - Py_BuildValue with the "O" format specifier transfers the new list's >> *sole* reference (= ownership) to the just-built higher-level object "args" > > Reference transfer is done with "N", not "O". That would be an > alternative to decreasing the refc...
2023 Feb 17
1
[PATCH 1/2] python: Avoid crash if callback parameters cannot be built
..., 3 deletions(-) > > > > diff --git a/python/handle.c b/python/handle.c > > index c8752baf47..f37e939e03 100644 > > --- a/python/handle.c > > +++ b/python/handle.c > > @@ -134,18 +134,21 @@ guestfs_int_py_event_callback_wrapper (guestfs_h *g, > > args = Py_BuildValue ("(Kis#O)", > > (unsigned PY_LONG_LONG) event, event_handle, > > buf, buf_len, py_array); According to https://docs.python.org/3/c-api/arg.html#building-values, "O" increments the count of py_array. So before the...
2023 Feb 14
2
[PATCH 1/2] python: Avoid crash if callback parameters cannot be built
...ml --- python/handle.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/python/handle.c b/python/handle.c index c8752baf47..f37e939e03 100644 --- a/python/handle.c +++ b/python/handle.c @@ -134,18 +134,21 @@ guestfs_int_py_event_callback_wrapper (guestfs_h *g, args = Py_BuildValue ("(Kis#O)", (unsigned PY_LONG_LONG) event, event_handle, buf, buf_len, py_array); + if (args == NULL) { + PyErr_PrintEx (0); + goto out; + } + Py_INCREF (args); - py_r = PyObject_CallObject (py_callback, args); - Py_DECRE...
2023 Feb 14
2
[PATCH 2/2] python: Use bytes instead of str for event callback buffer
...eletion(-) diff --git a/python/handle.c b/python/handle.c index f37e939e03..bf639b5789 100644 --- a/python/handle.c +++ b/python/handle.c @@ -131,7 +131,7 @@ guestfs_int_py_event_callback_wrapper (guestfs_h *g, } /* XXX As with Perl we don't pass the guestfs_h handle here. */ - args = Py_BuildValue ("(Kis#O)", + args = Py_BuildValue ("(Kiy#O)", (unsigned PY_LONG_LONG) event, event_handle, buf, buf_len, py_array); if (args == NULL) { -- 2.39.0
2005 Oct 13
2
[PATCH] sedf get in XendClient API
...e my code base is EXTREMELY old... however the code is still valid) tools/python/xen/lowlevel/xc/xc.c line 766 static PyObject *pyxc_sedf_domain_get(PyObject *self, PyObject *args, PyObject *kwds) ... - return Py_BuildValue("{s:i,s:L,s:L,s:L,s:i}", - "domain", domid, - "period", period, - "slice", slice, - "latency", latency, - "extratime", extratime); + return Py_B...
2018 Apr 11
0
[nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...uint64_t offset, uint32_t flags) { - PyObject *obj = handle; + ConnHandle *h = handle; PyObject *fn; PyObject *args; PyObject *kwargs; @@ -516,7 +531,7 @@ py_pwrite (void *handle, const void *buf, if (callback_defined ("pwrite", &fn)) { PyErr_Clear (); - args = Py_BuildValue ("ONL", obj, + args = Py_BuildValue ("ONL", h->obj, PyByteArray_FromStringAndSize (buf, count), offset); if (!args) { @@ -559,7 +574,7 @@ py_pwrite (void *handle, const void *buf, static int py_flush (void *hand...
2018 Apr 19
1
Re: [nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...ct *obj = handle; > + ConnHandle *h = handle; > PyObject *fn; > PyObject *args; > PyObject *kwargs; > @@ -516,7 +531,7 @@ py_pwrite (void *handle, const void *buf, > if (callback_defined ("pwrite", &fn)) { > PyErr_Clear (); > > - args = Py_BuildValue ("ONL", obj, > + args = Py_BuildValue ("ONL", h->obj, > PyByteArray_FromStringAndSize (buf, count), > offset); > if (!args) { > @@ -559,7 +574,7 @@ py_pwrite (void *handle, const void *buf, > st...
2018 Apr 06
6
[nbdkit PATCH 0/2] Python cleanups
I noticed these while working on adding fua support into python, these are independent enough to push now (and I'll have to rebase my 'optional may_trim' patch on top of this). Eric Blake (2): python: Use Py_XDEFREF() python: Simplify calling into plugin plugins/python/python.c | 106 ++++++++---------------------------------------- 1 file changed, 18 insertions(+), 88
2018 Apr 11
10
[nbdkit PATCH v2 0/5] FUA support in Python scripts
First out of our four language bindings to add FUA support (for reference, I added 'zero' support for python, perl, and ruby back in 1.1.13, then Rich had to add it for ocaml in 1.1.20). I tested this heavily under python 2, but for now only compile tested under python 3; I plan to do further testing there and make any tweaks if necessary. I wrote patch 5 early on, but then realized I
2006 Jul 31
1
[PATCH 5/6] xen, tools: calculate nr_cpus via num_online_cpus
...90 tools/python/xen/lowlevel/xc/xc.c --- a/tools/python/xen/lowlevel/xc/xc.c Mon Jul 31 10:48:48 2006 -0500 +++ b/tools/python/xen/lowlevel/xc/xc.c Mon Jul 31 10:49:10 2006 -0500 @@ -631,10 +631,11 @@ static PyObject *pyxc_physinfo(XcObject if(q>cpu_cap) *(q-1)=0; - ret_obj = Py_BuildValue("{s:i,s:i,s:i,s:l,s:l,s:l,s:i,s:s}", + ret_obj = Py_BuildValue("{s:i,s:i,s:i,s:i,s:l,s:l,s:l,s:i,s:s}", "threads_per_core", info.threads_per_core, "cores_per_socket", info.cores_per_socket,...
2008 Aug 30
3
Updated version of patch
Attached is a patch against shout-python-0.2 which does two trivial but very useful things (1) The function "get_connected" is exported so that shout-python becomes usable in nonblocking mode. In the current version of shout-python "open" raises an exception in nonblocking mode. (2) The global interpreter lock is released in the potentially blocking functions
2023 Feb 17
1
[PATCH] python: Avoid leaking py_array along error paths
...buf, buf_len, py_array); > if (args == NULL) { > PyErr_PrintEx (0); > + Py_DECREF (py_array); > goto out; > } See my response in the other thread. You are also leaking args, which is not fixed here. I think the correct sequence is: py_array = ... args = Py_BuildValue("...O", py_array); Py_DECREF (py_array); if (args == NULL) { PyErr_PrintEx (0); goto out; } ... out: Py_DECREF (args); -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
2007 Feb 26
2
[PATCH 0 of 2] Parse image elfnotes, write them to xenstore, save and load via image sxpr
Here are two patches that let xm create, save and restore extract and preserve elfnotes read by the domain builder. This is handy for a few things. In particular, I''d like it so that xm can decide whether or not guest domains support fast resume (if save fails, or for checkpointing). _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com
2006 Sep 29
4
[PATCH 4/6] xen: export NUMA topology in physinfo hcall
...BLIC_MAX_NUMNODES ); + set_xen_guest_handle(info.node_to_cpu, map); + if ( xc_physinfo(self->xc_handle, &info) != 0 ) return PyErr_SetFromErrno(xc_error); @@ -489,16 +502,56 @@ static PyObject *pyxc_physinfo(XcObject if(q>cpu_cap) *(q-1)=0; - return Py_BuildValue("{s:i,s:i,s:i,s:i,s:l,s:l,s:l,s:i,s:s}", - "threads_per_core", info.threads_per_core, - "cores_per_socket", info.cores_per_socket, - "sockets_per_node", info.sockets_per_node, -...
2018 Apr 06
1
[nbdkit PATCH] python: Let zero's may_trim parameter be optional
...tem (args, 0, obj); PyTuple_SetItem (args, 1, PyLong_FromUnsignedLongLong (count)); PyTuple_SetItem (args, 2, PyLong_FromUnsignedLongLong (offset)); - PyTuple_SetItem (args, 3, PyBool_FromLong (may_trim)); - r = PyObject_CallObject (fn, args); + if (zero_may_trim) + kwargs = Py_BuildValue("{s:i}", "may_trim", may_trim); + r = PyObject_Call (fn, args, kwargs); Py_DECREF (fn); Py_DECREF (args); + Py_XDECREF (kwargs); if (last_error == EOPNOTSUPP) { /* When user requests this particular error, we want to gracefully fall back, a...
2019 Jul 24
2
Re: [PATCH libnbd 1/3] generator: Change Closure so it describes single callbacks.
...) cls; > - pr " free (user_data);\n"; > + pr " Py_DECREF (user_data);\n"; > pr "}\n"; > pr "\n"; > ); ... (lots of churn due to reindentation, such is life) > + pr " py_args = Py_BuildValue (\"(\""; > + List.iter ( > + function > + | ArrayAndLen (UInt32 n, len) -> pr " \"O\"" > + | BytesIn (n, len) -> pr " \"y#\"" > + | Int n -> pr " \"i\"" > +...
2018 Apr 06
0
[nbdkit PATCH 2/2] python: Simplify calling into plugin
PyObject_CallObject is powerful, but awkward - we have to wrap all arguments into a temporary tuple before using it. Let python do more of the work by using PyObject_CallFunction anywhere that all arguments can be described by a Py_BuildValue() format string, instead of creating one-shot arguments ourselves. In fact, for our py_config(), this makes it easier to not worry about python 2 String vs. python 3 Unicode. Similarly, PyObject_CallFunctionObjArgs is nicer when we already have PyObjects for all parameters (including in py_open()...
2019 Aug 13
0
[PATCH libnbd 2/6] generator: Create only one Python wrapper per closure.
...t;, \"i\", *%s);\n" n n n; + pr " if (!py_%s) { PyErr_PrintEx (0); return -1; }\n" n; + | CBString _ + | CBUInt _ + | CBUInt64 _ -> () + | CBArrayAndLen _ | CBMutable _ -> assert false + ) cbargs; + pr "\n"; + + pr " py_args = Py_BuildValue (\"(\""; + List.iter ( + function + | CBArrayAndLen (UInt32 n, len) -> pr " \"O\"" + | CBBytesIn (n, len) -> pr " \"y#\"" + | CBInt n -> pr " \"i\"" + | CBInt64 n -> pr " \"L\"&quo...
2023 Feb 14
1
Issue with downloading files whose path contains multi-byte utf-8 characters
...gt; > On Mon, Feb 13, 2023 at 10:16 PM Richard W.M. Jones <rjones at redhat.com> wrote: > > On Mon, Feb 13, 2023 at 09:38:50PM +0200, Yonatan Shtarkman wrote: > > Also, as a workaround, I avoided calling the event callback if null is > returned > > by?Py_BuildValue (still print the error and release the thread). > > This seems to work for our usage (we only use the event callbacks for > logging), > > any potential?issues?I'm missing? > > Oh I see so the issue is actually when logging and not in the download >...