Displaying 20 results from an estimated 36 matches for "pyexc_typeerror".
2014 Aug 08
2
[PATCH 1/2] Add type checking, support integers as value
...put_handle (hive_h *h)
* not be freed.
*/
static int
-get_value (PyObject *v, hive_set_value *ret)
+get_value (PyObject *v, hive_set_value *ret, uint64_t *word)
{
PyObject *obj;
-#ifndef HAVE_PYSTRING_ASSTRING
PyObject *bytes;
-#endif
+
+ if (!PyDict_Check (v)) {
+ PyErr_SetString (PyExc_TypeError, \"expected dictionary type for value\");
+ return -1;
+ }
obj = PyDict_GetItemString (v, \"key\");
if (!obj) {
- PyErr_SetString (PyExc_RuntimeError, \"no 'key' element in dictionary\");
+ PyErr_SetString (PyExc_KeyError, \"no 'key...
2017 May 11
1
[PATCH] python: improve few exceptions thrown on error
..._SetNone (PyExc_MemoryError);
+ PyErr_NoMemory ();
return NULL;
}
@@ -298,7 +298,7 @@ guestfs_int_py_get_string_list (PyObject *obj)
assert (obj);
if (!PyList_Check (obj)) {
- PyErr_SetString (PyExc_RuntimeError, "expecting a list parameter");
+ PyErr_SetString (PyExc_TypeError, "expecting a list parameter");
return NULL;
}
@@ -310,7 +310,7 @@ guestfs_int_py_get_string_list (PyObject *obj)
len = (size_t) slen;
r = malloc (sizeof (char *) * (len+1));
if (r == NULL) {
- PyErr_SetString (PyExc_RuntimeError, "get_string_list: out of memory...
2020 Sep 08
2
[libnbd PATCH] python: Plug some memory leaks on error paths
...ure { 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 " %s_user_data->fn = NULL;\n" cbname;
+ pr " goto out;\n";
+...
2019 Aug 13
1
Re: [PATCH libnbd v2 1/3] generator: Implement OClosure.
...bname;
> + 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 we fail to do a matching Py_DECREF on
failure paths. It would be easier to defer the Py_INCREF...
2020 Sep 10
1
[libnbd PATCH] python: Fix more memory leaks
...ser_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 " /* Increment refcount since pointer may be saved by libnbd. */\n";
+ pr &...
2019 Jul 16
1
Re: [PATCH libnbd v2] generator: Define new Closure type instead of callbacks.
...(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"
> + | Closure (_, cls) ->
> + List.iter (
> + fun { cb...
2014 Aug 04
6
[hivex] Segfault for an integer value to node_set_value
Hi,
When an integer argument is passed as value, node_set_value
segfaults. Reproducer is at the end of this message
The backtrace points at hivex-py.c, function get_value. While obj
is non-NULL, `bytes = PyUnicode_AsUTF8String (obj);` returns NULL.
Kind regards,
Peter
https://lekensteyn.nl
#!/usr/bin/env python3
import hivex, sys
h = hivex.Hivex(sys.argv[1])
print(h)
val = {
2014 Aug 16
7
[hivex] [PATCH 0/6] Python fixes for node_set_value
Hi,
This patch series is based on a prior patch[1], splitting off changes as
requested and incorporating feedback from Richard Jones. It introduces type
validation to avoid segmentation faults (instead, it reports an exception) and
fixes handling of the bytes type in Python 3.
Major changes since that series:
- Drop newly introduced support for integer types for DWORD/QWORDS
- Reject Unicode
2019 Aug 12
0
[PATCH libnbd 6/7] python: Use free callback to free closure root.
...Py_DECREF ((PyObject *)user_data);\n";
- pr "\n";
pr " return ret;\n";
pr "}\n";
pr "\n"
@@ -4454,6 +4451,11 @@ let print_python_binding name { args; optargs; ret; may_set_error } =
pr " PyErr_SetString (PyExc_TypeError,\n";
pr " \"callback parameter %s is not callable\");\n" cbname;
pr " return NULL;\n";
+ pr " }\n";
+ pr " if (nbd_add_free_callback (h, %s_user_data,\n" cbname;
+ pr "...
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 24
2
Re: [PATCH libnbd 2/3] lib: Implement closure lifetimes.
...ut (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/states-reply-simple.c
I got this far in my review; I'll resume later...
--
Eric Blake,...
2019 Aug 13
0
[PATCH libnbd 5/6] generator: Implement OClosure.
...er_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 " }\n"
| OFlags (n, _) -> pr " %s_u32 = %s;\n" n n
) optar...
2019 Aug 13
0
[PATCH libnbd v2 1/3] generator: Implement OClosure.
...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 " }\n"
| OFlags (n, _) -> pr " %s_u32 = %s;\n" n n
) optar...
2019 Jul 24
0
Re: [PATCH libnbd 2/3] lib: Implement closure lifetimes.
...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?
Yes, I'll fix this too.
Thanks for this - I'll post an updated patch with all the changes
r...
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 Aug 13
2
Re: [PATCH libnbd 5/6] generator: Implement OClosure.
...ser_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 " \"callback parameter %s is not callable\");\n" cbname;
> + pr " return NULL;\n";
> + pr " }\n";
> + pr " }\n"
> | OFlags (n, _) -> pr " %s_u32 = %...
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
...| 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 -> pr " %s_u32 = %s;\n" n n
| Int _ -> ()
| Int64 n -> pr...
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(-)
--
2019 Aug 13
0
[PATCH libnbd 1/4] api: Combine callback and user_data into a single struct.
..." 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 %s is not callable\");\n" cbname;
pr " return NULL;\n";
@@ -4289,15 +4291,17 @@ let print_python_binding name { args; optargs; ret; may_set_error } =
List.iter (
function
| OClosure...