On 6/28/19 1:27 PM, Richard W.M. Jones wrote:
Previously errors caused a RuntimeException to be raised. This commit defines a custom exception (nbd.Error) which has two parameters, the required error string, and the optional errno (which may be 0 if unavailable).
+static inline void +raise_exception () +{ + PyObject *args = PyTuple_New (2); + + PyTuple_SetItem (args, 0, PyUnicode_FromString (nbd_get_error ())); + PyTuple_SetItem (args, 1, PyLong_FromLong (nbd_get_errno ()));
These three lines could probably be compressed into: Py_BuildValue("si", nbd_get_error(), nbd_get_errno ()); I'll look for other shortcuts like that while auditing for proper error checking. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org