Displaying 20 results from an estimated 28 matches for "py_xdecref".
Did you mean:
py_decref
2018 Apr 06
0
[nbdkit PATCH 1/2] python: Use Py_XDEFREF()
..., 3 insertions(+), 6 deletions(-)
diff --git a/plugins/python/python.c b/plugins/python/python.c
index 35e8df2..c5cc4bd 100644
--- a/plugins/python/python.c
+++ b/plugins/python/python.c
@@ -183,8 +183,7 @@ py_load (void)
static void
py_unload (void)
{
- if (module)
- Py_DECREF (module);
+ Py_XDECREF (module);
Py_Finalize ();
}
@@ -346,8 +345,7 @@ py_close (void *handle)
Py_DECREF (fn);
Py_DECREF (args);
check_python_failure ("close");
- if (r)
- Py_DECREF (r);
+ Py_XDECREF (r);
}
Py_DECREF (obj);
@@ -550,8 +548,7 @@ py_zero (void *handle, uint32_...
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
2020 Sep 10
1
[libnbd PATCH] python: Fix more memory leaks
...; free_user_data (%s_user_data);\n" cbname
| OFlags _ -> ()
) optargs;
pr " return py_ret;\n";
@@ -613,9 +608,11 @@ let generate_python_methods_c () =
pr "{\n";
pr " struct user_data *data = user_data;\n";
pr "\n";
- pr " Py_XDECREF (data->fn);\n";
- pr " Py_XDECREF (data->buf);\n";
- pr " free (data);\n";
+ pr " if (data) {\n";
+ pr " Py_XDECREF (data->fn);\n";
+ pr " Py_XDECREF (data->buf);\n";
+ pr " free (data);\n";
+ pr "...
2017 Mar 03
5
[PATCH v2 0/4] Avoid 0-bytes malloc in bindings
Hi,
some of the bindings may try to malloc with 0 bytes as size when closing
an handle, because there were no event handlers registered. Since this
can have different behaviours in POSIX, avoid that situation altogether
by just skipping allocating anything when there were no event handlers.
Thanks,
Pino Toscano (4):
ocaml: do not try to malloc 0 elements in get_all_event_callbacks
python:
2020 Sep 08
2
[libnbd PATCH] python: Plug some memory leaks on error paths
...quot;;
pr " struct user_data *data = user_data;\n";
pr "\n";
- pr " if (data->fn != NULL)\n";
- pr " Py_DECREF (data->fn);\n";
- pr " if (data->buf != NULL)\n";
- pr " Py_DECREF (data->buf);\n";
+ pr " Py_XDECREF (data->fn);\n";
+ pr " Py_XDECREF (data->buf);\n";
pr " free (data);\n";
pr "}\n";
pr "\n";
--
2.28.0
2019 Nov 22
0
[PATCH nbdkit v2 01/10] python: Use PyObject_CallFunction instead of constructing the tuple.
...want to
- gracefully fall back, and to accomodate both a normal return
- and an exception. */
+ * gracefully fall back, and to accomodate both a normal return
+ * and an exception.
+ */
nbdkit_debug ("zero requested falling back to pwrite");
Py_XDECREF (r);
PyErr_Clear ();
--
2.23.0
2019 Nov 21
0
[PATCH nbdkit 1/8] python: Use PyObject_CallFunction instead of constructing the tuple.
...want to
- gracefully fall back, and to accomodate both a normal return
- and an exception. */
+ * gracefully fall back, and to accomodate both a normal return
+ * and an exception.
+ */
nbdkit_debug ("zero requested falling back to pwrite");
Py_XDECREF (r);
PyErr_Clear ();
--
2.23.0
2019 Jun 27
1
[libnbd PATCH] python: Fix bindings for Path parameters
...ckAddrAndLen not implemented */\n";
| String _ -> ()
@@ -3860,7 +3864,8 @@ let print_python_binding name { args; ret } =
| Int64 _ -> ()
| Mutable _ -> ()
| Opaque _ -> ()
- | Path n -> pr " free (%s);\n" n
+ | Path n ->
+ pr " Py_XDECREF (py_%s);\n" n
| SockAddrAndLen _ -> ()
| String n -> ()
| StringList n -> pr " nbd_internal_py_free_string_list (%s);\n" n
--
2.20.1
2020 Aug 05
5
[PATCH nbdkit 3/4] python: Allow thread model to be set from Python plugins.
This is working for me now, although possibly only on Python 3.9.
Dan suggested PyEval_InitThreads but that was deprecated in
Python 3.7.
Rich.
2018 Apr 06
0
[nbdkit PATCH 2/2] python: Simplify calling into plugin
...e_New (1);
- Py_INCREF (obj); /* decremented by Py_DECREF (args) */
- PyTuple_SetItem (args, 0, obj);
- r = PyObject_CallObject (fn, args);
+ r = PyObject_CallFunctionObjArgs (fn, obj, NULL);
Py_DECREF (fn);
- Py_DECREF (args);
check_python_failure ("close");
Py_XDECREF (r);
}
@@ -356,7 +338,6 @@ py_get_size (void *handle)
{
PyObject *obj = handle;
PyObject *fn;
- PyObject *args;
PyObject *r;
int64_t ret;
@@ -367,12 +348,8 @@ py_get_size (void *handle)
PyErr_Clear ();
- args = PyTuple_New (1);
- Py_INCREF (obj); /* decremented by Py_DECREF...
2018 Apr 11
0
[nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...PyObject *fn;
PyObject *r;
if (callback_defined ("close", &fn)) {
PyErr_Clear ();
- r = PyObject_CallFunctionObjArgs (fn, obj, NULL);
+ r = PyObject_CallFunctionObjArgs (fn, h->obj, NULL);
Py_DECREF (fn);
check_python_failure ("close");
Py_XDECREF (r);
}
- Py_DECREF (obj);
+ Py_DECREF (h->obj);
+ free (h);
}
static int64_t
py_get_size (void *handle)
{
- PyObject *obj = handle;
+ ConnHandle *h = handle;
PyObject *fn;
PyObject *r;
int64_t ret;
@@ -445,7 +460,7 @@ py_get_size (void *handle)
PyErr_Clear ();
- r =...
2019 Oct 04
0
[PATCH libnbd 3/4] api: Add nbd_connect_socket.
...| SockAddrAndLen _
@@ -5142,7 +5180,7 @@ let print_python_binding name { args; optargs; ret; may_set_error } =
| Closure _ -> ()
| Enum _ -> ()
| Flags _ -> ()
- | Int _ -> ()
+ | Fd _ | Int _ -> ()
| Int64 _ -> ()
| Path n ->
pr " Py_XDECREF (py_%s);\n" n
@@ -5351,7 +5389,7 @@ class NBD (object):
| Closure { cbname } -> cbname, None, None
| Enum (n, _) -> n, None, None
| Flags (n, _) -> n, None, None
- | Int n -> n, None, None
+ | Fd n | Int n -> n, None, None...
2018 Apr 06
1
[nbdkit PATCH] python: Let zero's may_trim parameter be optional
...- 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, and to accomodate both a normal return
diff --git a/plugins/python/example.py b/plugins/python/example.py
index 60f9d7f..9205f10 100644
--- a/plugins/python/...
2018 Apr 19
1
Re: [nbdkit PATCH v2 5/5] RFC: python: Track and cache per-connection state in C struct
...if (callback_defined ("close", &fn)) {
> PyErr_Clear ();
>
> - r = PyObject_CallFunctionObjArgs (fn, obj, NULL);
> + r = PyObject_CallFunctionObjArgs (fn, h->obj, NULL);
> Py_DECREF (fn);
> check_python_failure ("close");
> Py_XDECREF (r);
> }
>
> - Py_DECREF (obj);
> + Py_DECREF (h->obj);
> + free (h);
> }
>
> static int64_t
> py_get_size (void *handle)
> {
> - PyObject *obj = handle;
> + ConnHandle *h = handle;
> PyObject *fn;
> PyObject *r;
> int64_t ret;...
2020 Sep 29
2
[PATCH libnbd] generator: Add SizeT type, maps to C size_t.
...args; ret; may_set_error } =
| Int64 _
| Path _
| SockAddrAndLen _
+ | SizeT _
| String _
| StringList _
| UInt _
@@ -551,6 +556,7 @@ let print_python_binding name { args; optargs; ret; may_set_error } =
| Int64 _ -> ()
| Path n ->
pr " Py_XDECREF (py_%s);\n" n
+ | SizeT _ -> ()
| SockAddrAndLen _ -> ()
| String n -> ()
| StringList n -> pr " nbd_internal_py_free_string_list (%s);\n" n
@@ -791,6 +797,7 @@ class NBD(object):
| Fd n | Int n -> n, None, None
| Int64 n ->...
2018 Apr 11
10
[nbdkit PATCH v2 0/5] FUA support in Python scripts
...(It would matter
if we ever had any per-connection state beyond the script's
handle, and which would not also be cached on our behalf by
the main nbdkit code).
Something I thought of while writing patch 4, but haven't explored
yet, would be using attribute((cleanup)) to automatically call
Py_XDECREF() in a lot more places, for more compact code (it felt
like a lot of boilerplate to avoid leaks of python objects on all
exit paths).
Eric Blake (5):
python: Let zero's may_trim parameter be optional
python: Expose can_zero callback
python: Update internals to plugin API level 2
python...
2019 Aug 14
5
[PATCH libnbd 0/3] Use free callback to hold ref to AIO buffer.
Basically the same as this patch series, but for Python:
https://www.redhat.com/archives/libguestfs/2019-August/msg00235.html
plus adding the 590 asynch test at the end.
Rich.
2019 Nov 22
18
[PATCH nbdkit v2 00/10] Implement nbdkit API v2 for Python plugins.
v1:
https://www.redhat.com/archives/libguestfs/2019-November/msg00153.html
v2:
- Fix implementation of can_cache.
- Add implementation of can_fua.
- Add a very thorough test suite which tests every command + flag
combination.
2019 Oct 04
4
[PATCH libnbd 1/4] generator: Allow long ‘name - shortdesc’ in man pages.
For commands with long names and/or short descriptors, you can end up
going over 72 characters in the first line of the man page (causing
podwrapper to complain). Wrap these lines.
---
generator/generator | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/generator/generator b/generator/generator
index 7d3f656..ad1cb6b 100755
--- a/generator/generator
+++ b/generator/generator
2019 Nov 21
10
[PATCH nbdkit 0/8] Implement nbdkit API v2 for Python plugins.
And fill out most of the missing bits of the API.
Rich.