search for: pybytearray_check

Displaying 2 results from an estimated 2 matches for "pybytearray_check".

2019 Nov 23
1
[PATCH] python: Support buffer protocol for pread() result
...-1; + return ret; } PyErr_Clear (); @@ -456,25 +458,30 @@ py_pread (void *handle, void *buf, r = PyObject_CallFunction (fn, "OiL", obj, count, offset, NULL); Py_DECREF (fn); if (check_python_failure ("pread") == -1) - return -1; + return ret; - if (!PyByteArray_Check (r)) { - nbdkit_error ("%s: value returned from pread method is not a byte array", + if (PyObject_GetBuffer (r, &view, PyBUF_SIMPLE) == -1) { + nbdkit_error ("%s: value returned from pread does not support the " + "buffer protocol",...
2010 Sep 09
2
[PATCH]: add libxl python binding
...DINIT_FUNC DL_EXPORT(void) +#endif + +#define CLS "ctx" + +static PyObject *xl_error_obj; + +static int fixed_bytearray_set(PyObject *v, uint8_t *ptr, size_t len) +{ + char *tmp; + size_t sz; + + if ( NULL == v ) { + memset(ptr, 0, len); + return 0; + } + if ( PyByteArray_Check(v) ) { + sz = PyByteArray_Size(v); + tmp = PyByteArray_AsString(v); + }else{ + Py_ssize_t ssz; + if ( PyString_AsStringAndSize(v, &tmp, &ssz) ) + return -1; + if ( ssz < 0 ) + tmp = NULL; + sz = ssz; + } + if ( NULL...