search for: pylist_check

Displaying 7 results from an estimated 7 matches for "pylist_check".

2017 May 11
1
[PATCH] python: improve few exceptions thrown on error
...rtn) /* Copy them into the return array. */ r = malloc (sizeof (PyObject *) * (*len_rtn)); if (r == NULL) { - PyErr_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 = mall...
2020 Aug 10
5
[PATCH nbdkit] python: Implement can_extents + extents.
...t_CallFunction (fn, "OiLI", h->py_h, count, offset, flags); + Py_DECREF (fn); + if (check_python_failure ("extents") == -1) + return -1; + + /* We expect a list of extents to be returned. Each extent is a + * tuple (offset, length, type). + */ + if (!PyList_Check (r)) { + nbdkit_error ("extents method did not return a list"); + Py_DECREF (r); + return -1; + } + + size = PyList_Size (r); + for (i = 0; i < size; ++i) { + PyObject *t, *py_offset, *py_length, *py_type; + uint64_t extent_offset, extent_length; +...
2020 Aug 10
0
Re: [PATCH nbdkit] python: Implement can_extents + extents.
...>py_h, count, offset, flags); > + Py_DECREF (fn); > + if (check_python_failure ("extents") == -1) > + return -1; > + > + /* We expect a list of extents to be returned. Each extent is a > + * tuple (offset, length, type). > + */ > + if (!PyList_Check (r)) { > + nbdkit_error ("extents method did not return a list"); > + Py_DECREF (r); > + return -1; > + } > + > + size = PyList_Size (r); > + for (i = 0; i < size; ++i) { > + PyObject *t, *py_offset, *py_length, *py_type; > +...
2020 Aug 10
2
[PATCH nbdkit] python: Allow extents to return any iterable (which includes lists).
...25 @@ py_extents (void *handle, uint32_t count, uint64_t offset, if (check_python_failure ("extents") == -1) return -1; - /* We expect a list of extents to be returned. Each extent is a - * tuple (offset, length, type). The list must not be empty. - */ - if (!PyList_Check (r)) { - nbdkit_error ("extents method did not return a list"); - Py_DECREF (r); - return -1; - } - size = PyList_Size (r); - if (size < 1) { - nbdkit_error ("extents method cannot return an empty list"); + iter = PyObject_GetIter (r); + if...
2020 Aug 10
0
Re: [PATCH nbdkit] python: Implement can_extents + extents.
...>py_h, count, offset, flags); > + Py_DECREF (fn); > + if (check_python_failure ("extents") == -1) > + return -1; > + > + /* We expect a list of extents to be returned. Each extent is a > + * tuple (offset, length, type). > + */ > + if (!PyList_Check (r)) { This will work only with the list. We want to check if we got a type we can iterated on. I don't know the APi needed but I'm sure this is supported by the C API. > + nbdkit_error ("extents method did not return a list"); > + Py_DECREF (r); > + retu...
2019 Aug 09
0
[PATCH libnbd 1/2] generator: Handle closure args (cbargs) specially.
...pr ", &%s" n | String n -> pr ", &%s" n @@ -4245,24 +4234,6 @@ let print_python_binding name { args; ret; may_set_error } = pr " h = get_handle (py_h);\n"; List.iter ( function - | ArrayAndLen (UInt32 n, len) -> - pr " if (!PyList_Check (py_%s)) {\n" n; - pr " PyErr_SetString (PyExc_TypeError, \"expecting a list\");\n"; - pr " return NULL;\n"; - pr " }\n"; - pr " %s = PyList_Size (py_%s);\n" len n; - pr " if (%s == -1) {\n" len;...
2019 Aug 09
4
[PATCH libnbd 0/2] generator: Preparatory changes to the generator.
These are some simplifications to the generator. They don't probably make much sense on their own, but they are preparatory to better handling of enums, and or'd lists of flags. Rich.