search for: pycallable_check

Displaying 20 results from an estimated 31 matches for "pycallable_check".

2019 Aug 13
2
Re: [PATCH libnbd 5/6] generator: Implement OClosure.
...tion > + | OClosure { cbname } -> > + pr " if (%s_user_data) {\n" cbname; > + pr " /* Increment refcount since pointer may be saved by libnbd. */\n"; > + pr " Py_INCREF (%s_user_data);\n" cbname; > + pr " if (!PyCallable_Check (%s_user_data)) {\n" cbname; I don't think PyNone is callable; this probably needs to gain a special case for when the user omitted the optional argument and we thus... > + pr " PyErr_SetString (PyExc_TypeError,\n"; > + pr " \&q...
2020 Sep 10
1
[libnbd PATCH] python: Fix more memory leaks
...( + function + | OClosure { cbname } -> + pr " %s.user_data = %s_user_data = alloc_user_data ();\n" cbname cbname; + pr " if (%s_user_data == NULL) goto out;\n" cbname; + pr " if (py_%s_fn != Py_None) {\n" cbname; + pr " if (!PyCallable_Check (py_%s_fn)) {\n" cbname; + pr " PyErr_SetString (PyExc_TypeError,\n"; + pr " \"callback parameter %s is not callable\");\n" cbname; + pr " goto out;\n"; + pr " }\n"; + pr "...
2018 Apr 05
1
[nbdkit PATCH] python: Make sure callbacks are actually callable
.../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 callable", name); + Py_DECREF (obj); + return 0; + } if (obj_rtn != NULL) *obj_rtn = obj; -- 2.14.3
2020 Sep 08
2
[libnbd PATCH] python: Plug some memory leaks on error paths
...ror } = pr " %s_buf = nbd_internal_py_get_aio_buffer (%s);\n" n n | Closure { cbname } -> pr " /* Increment refcount since pointer may be saved by libnbd. */\n"; - pr " Py_INCREF (%s_user_data->fn);\n" cbname; pr " if (!PyCallable_Check (%s_user_data->fn)) {\n" cbname; pr " PyErr_SetString (PyExc_TypeError,\n"; pr " \"callback parameter %s is not callable\");\n" cbname; - pr " return NULL;\n"; - pr " }\n" + pr &qu...
2019 Aug 13
1
Re: [PATCH libnbd v2 1/3] generator: Implement OClosure.
...| OClosure { cbname } -> > + pr " if (%s_user_data != Py_None) {\n" cbname; > + pr " /* Increment refcount since pointer may be saved by libnbd. */\n"; > + pr " Py_INCREF (%s_user_data);\n" cbname; > + pr " if (!PyCallable_Check (%s_user_data)) {\n" cbname; > + pr " PyErr_SetString (PyExc_TypeError,\n"; > + pr " \"callback parameter %s is not callable\");\n" cbname; > + pr " return NULL;\n"; Leaks %s_user_data, because...
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 Jul 16
1
Re: [PATCH libnbd v2] generator: Define new Closure type instead of callbacks.
...et } = > pr " %s = malloc (%s);\n" n count > | BytesPersistIn (n, _) | BytesPersistOut (n, _) -> > pr " %s_buf = nbd_internal_py_get_aio_buffer (%s);\n" n n > - | Callback (n, _) | CallbackPersist (n, _) -> > - pr " if (!PyCallable_Check (%s_data->fn)) {\n" n; > - pr " PyErr_SetString (PyExc_TypeError,\n"; > - pr " \"callback parameter %s is not callable\");\n" > - n; > - pr " return NULL;\n"; > - pr " }\n...
2019 Aug 13
0
Re: [PATCH libnbd 5/6] generator: Implement OClosure.
...osure { cbname } -> > > + pr " if (%s_user_data) {\n" cbname; > > + pr " /* Increment refcount since pointer may be saved by libnbd. */\n"; > > + pr " Py_INCREF (%s_user_data);\n" cbname; > > + pr " if (!PyCallable_Check (%s_user_data)) {\n" cbname; > > I don't think PyNone is callable; this probably needs to gain a special > case for when the user omitted the optional argument and we thus... Yeah I'm not sure about this, plus we don't have any test coverage of it. But it doesn't wo...
2018 Aug 08
2
[PATCH nbdkit] python: Try harder to print the full traceback on error.
...ouldn't 'import traceback' */ + if (traceback_module == NULL) + return -1; + + format_exception_fn = PyObject_GetAttrString (traceback_module, + "format_exception"); + if (format_exception_fn == NULL) + return -1; + if (!PyCallable_Check (format_exception_fn)) + return -1; + + rv = PyObject_CallFunctionObjArgs (format_exception_fn, + type, error, traceback, NULL); + traceback_str = PyObject_Str (rv); + traceback_cstr = python_to_string (traceback_str); + if (traceback_cstr == NULL) { +...
2019 Jul 24
2
Re: [PATCH libnbd 2/3] lib: Implement closure lifetimes.
...pr " %s = malloc (%s);\n" n count > | BytesPersistIn (n, _) | BytesPersistOut (n, _) -> > pr " %s_buf = nbd_internal_py_get_aio_buffer (%s);\n" n n > - | Closure (_, { cbname }) -> > + | Closure { cbname } -> > pr " if (!PyCallable_Check (%s_user_data)) {\n" cbname; > pr " PyErr_SetString (PyExc_TypeError,\n"; > pr " \"callback parameter %s is not callable\");\n" cbname; ...and this match are identical, should we group the code? > +++ b/generator/...
2019 Aug 13
0
[PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
..._set_error } = pr " %s_buf = nbd_internal_py_get_aio_buffer (%s);\n" n n | Closure { cbname } -> pr " /* Increment refcount since pointer may be saved by libnbd. */\n"; - pr " Py_INCREF (%s_user_data);\n" cbname; - pr " if (!PyCallable_Check (%s_user_data)) {\n" cbname; + pr " Py_INCREF (%s.user_data);\n" cbname; + pr " if (!PyCallable_Check (%s.user_data)) {\n" cbname; pr " PyErr_SetString (PyExc_TypeError,\n"; pr " \"callback parameter %...
2019 Aug 13
0
[PATCH libnbd 5/6] generator: Implement OClosure.
...List.iter ( function + | OClosure { cbname } -> + pr " if (%s_user_data) {\n" cbname; + pr " /* Increment refcount since pointer may be saved by libnbd. */\n"; + pr " Py_INCREF (%s_user_data);\n" cbname; + pr " if (!PyCallable_Check (%s_user_data)) {\n" cbname; + pr " PyErr_SetString (PyExc_TypeError,\n"; + pr " \"callback parameter %s is not callable\");\n" cbname; + pr " return NULL;\n"; + pr " }\n"; + pr &...
2019 Aug 13
0
[PATCH libnbd v2 1/3] generator: Implement OClosure.
...er ( function + | OClosure { cbname } -> + pr " if (%s_user_data != Py_None) {\n" cbname; + pr " /* Increment refcount since pointer may be saved by libnbd. */\n"; + pr " Py_INCREF (%s_user_data);\n" cbname; + pr " if (!PyCallable_Check (%s_user_data)) {\n" cbname; + pr " PyErr_SetString (PyExc_TypeError,\n"; + pr " \"callback parameter %s is not callable\");\n" cbname; + pr " return NULL;\n"; + pr " }\n"; + pr &...
2019 Jul 24
0
Re: [PATCH libnbd 2/3] lib: Implement closure lifetimes.
...s);\n" n count > > | BytesPersistIn (n, _) | BytesPersistOut (n, _) -> > > pr " %s_buf = nbd_internal_py_get_aio_buffer (%s);\n" n n > > - | Closure (_, { cbname }) -> > > + | Closure { cbname } -> > > pr " if (!PyCallable_Check (%s_user_data)) {\n" cbname; > > pr " PyErr_SetString (PyExc_TypeError,\n"; > > pr " \"callback parameter %s is not callable\");\n" cbname; > > ...and this match are identical, should we group the code? Ye...
2018 Aug 08
0
Re: [PATCH nbdkit] python: Try harder to print the full traceback on error.
.../ > + if (traceback_module == NULL) > + return -1; > + > + format_exception_fn = PyObject_GetAttrString (traceback_module, > + "format_exception"); > + if (format_exception_fn == NULL) > + return -1; > + if (!PyCallable_Check (format_exception_fn)) > + return -1; > + > + rv = PyObject_CallFunctionObjArgs (format_exception_fn, > + type, error, traceback, NULL); > + traceback_str = PyObject_Str (rv); > + traceback_cstr = python_to_string (traceback_str); > +...
2019 Aug 15
13
[PATCH libnbd v2 00/10] Callbacks and OCaml and Python persistent buffers.
This is a combination of these two earlier series: https://www.redhat.com/archives/libguestfs/2019-August/msg00235.html https://www.redhat.com/archives/libguestfs/2019-August/msg00240.html plus changes to allow .callback = NULL / .free != NULL, and to reduce the complexity of freeing callbacks. Although it's rather long there's nothing complex here. We might consider squashing some
2019 Aug 13
7
[PATCH libnbd v2 0/3] Implement OClosures.
v1 was here: https://www.redhat.com/archives/libguestfs/2019-August/msg00168.html I pushed uncontroversial patches 1-4 v2: - The implementation of OClosure (new patch 1) in Python is fixed. - Patch 2 (old patch 5) is unchanged. - I added a new API for removing debug callbacks. I think this approach has some advantages over using OClosure. - I didn't yet do any work on changing the
2019 Jul 16
2
[PATCH libnbd v2] generator: Define new Closure type
As before, but this one has working Python bindings. OCaml still TBD. Rich.
2019 Jul 16
0
[libnbd PATCH 2/2] RFC: generator: Handle shared callbacks in Python
...on_binding name { args; ret } = pr " %s = malloc (%s);\n" n count | BytesPersistIn (n, _) | BytesPersistOut (n, _) -> pr " %s_buf = nbd_internal_py_get_aio_buffer (%s);\n" n n - | Callback (n, _) | CallbackPersist (n, _) -> - pr " if (!PyCallable_Check (%s_data->fn)) {\n" n; - pr " PyErr_SetString (PyExc_TypeError,\n"; - pr " \"callback parameter %s is not callable\");\n" - n; - pr " return NULL;\n"; - pr " }\n" | Flags n -&g...
2019 Jul 16
3
[RFC libnbd PATCH 0/2] Start fixing python nbd.pread_structured_callback
Posting now that I got something to compile (at the expense of breaking OCaml bindings), but I'm open to ideas on how to improve it. Eric Blake (2): generator: Tweak print_c_arg_list to take alternate first arg RFC: generator: Handle shared callbacks in Python generator/generator | 556 ++++++++++++++++++++++---------------------- 1 file changed, 280 insertions(+), 276 deletions(-) --