search for: 35e8df2

Displaying 4 results from an estimated 4 matches for "35e8df2".

2018 Apr 05
1
[nbdkit PATCH] python: Make sure callbacks are actually callable
...in. Signed-off-by: Eric Blake <eblake@redhat.com> --- Various examples on calling Python functions from C recommend doing this filtering check. plugins/python/python.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/python/python.c b/plugins/python/python.c index 0206b80..35e8df2 100644 --- a/plugins/python/python.c +++ b/plugins/python/python.c @@ -94,6 +94,11 @@ callback_defined (const char *name, PyObject **obj_rtn) obj = PyObject_GetAttrString (module, name); if (!obj) return 0; + if (!PyCallable_Check (obj)) { + nbdkit_debug ("object %s isn't ca...
2018 Apr 06
0
[nbdkit PATCH 1/2] python: Use Py_XDEFREF()
No need to do a NULL check ourself, when we can just use the write Python wrapper. Signed-off-by: Eric Blake <eblake@redhat.com> --- plugins/python/python.c | 9 +++------ 1 file changed, 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);...
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 06
1
[nbdkit PATCH] python: Let zero's may_trim parameter be optional
...the optional parameter, or if the caller sets +it to False, writing zeroes should not punch holes. NBD only supports whole writes, so your function should try to write the whole region (perhaps requiring a loop). If the write diff --git a/plugins/python/python.c b/plugins/python/python.c index 35e8df2..d944905 100644 --- a/plugins/python/python.c +++ b/plugins/python/python.c @@ -64,6 +64,8 @@ static PyObject *module; static int last_error; +static int zero_may_trim = -1; + static PyObject * set_error (PyObject *self, PyObject *args) { @@ -108,6 +110,68 @@ callback_defined (const char *nam...