search for: pyexc_runtimeerror

Displaying 16 results from an estimated 16 matches for "pyexc_runtimeerror".

2017 May 11
1
[PATCH] python: improve few exceptions thrown on error
...s(-) diff --git a/python/handle.c b/python/handle.c index 88024e1..9746dca 100644 --- a/python/handle.c +++ b/python/handle.c @@ -237,7 +237,7 @@ guestfs_int_py_event_to_string (PyObject *self, PyObject *args) str = guestfs_event_to_string (events); if (str == NULL) { - PyErr_SetString (PyExc_RuntimeError, strerror (errno)); + PyErr_SetFromErrno (PyExc_RuntimeError); return NULL; } @@ -271,7 +271,7 @@ get_all_event_callbacks (guestfs_h *g, size_t *len_rtn) /* Copy them into the return array. */ r = malloc (sizeof (PyObject *) * (*len_rtn)); if (r == NULL) { - PyErr_SetNone (...
2017 Mar 18
0
[PATCH] python: check return value of Python APIs
...t; list = PyList_New (%ss->len);\n" typ; - pr " for (i = 0; i < %ss->len; ++i)\n" typ; - pr " PyList_SetItem (list, i, guestfs_int_py_put_%s (&%ss->val[i]));\n" typ typ; + pr " if (list == NULL)\n"; + pr " PyErr_SetString (PyExc_RuntimeError, \"PyList_New\");\n"; + pr " return NULL;\n"; + pr " }\n"; + pr " for (i = 0; i < %ss->len; ++i) {\n" typ; + pr " element = guestfs_int_py_put_%s (&%ss->val[i]);\n" typ typ; + pr " if (element == NULL...
2017 Apr 25
1
[Bug #1406906] [PATCH] python: fix segmentation fault when setting non UTF-8 strings
...list = PyList_New (%ss->len);\n" typ; - pr " for (i = 0; i < %ss->len; ++i)\n" typ; - pr " PyList_SetItem (list, i, guestfs_int_py_put_%s (&%ss->val[i]));\n" typ typ; + pr " if (list == NULL) {\n"; + pr " PyErr_SetString (PyExc_RuntimeError, \"PyList_New\");\n"; + pr " return NULL;\n"; + pr " }\n"; + pr " for (i = 0; i < %ss->len; ++i) {\n" typ; + pr " element = guestfs_int_py_put_%s (&%ss->val[i]);\n" typ typ; + pr " if (element == NULL...
2014 Aug 08
2
[PATCH 1/2] Add type checking, support integers as value
...*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' element in dictionary\"); + return -1; + } + if (PyUnicode_Check (obj)) { + bytes = PyUnicode_AsUTF8String (obj); + if (bytes == NULL) { + return -1; + } +...
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 = {
2019 Jun 28
3
[PATCH libnbd v2] python: Raise a custom exception containing error string and errno.
This kind of fixes the problems in v1. The exception still primarily lives in the libnbdmod and you could still refer to it using libnbdmod.Error (but don't do that). However when the exception is printed it now appears as nbd.Error, and you can catch it also using the same name. Other problems: - There is no "nice" interface to accessing the exception fields. You have to use
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 Jun 28
0
[PATCH libnbd v2] python: Raise a custom exception containing error string and errno.
...rror); + return mod; } " @@ -3796,7 +3825,7 @@ let print_python_binding name { args; ret } = | RBool | RErr | RFd | RInt | RInt64 -> pr " if (ret == -1) {\n"; | RConstString | RString -> pr " if (ret == NULL) {\n"; ); - pr " PyErr_SetString (PyExc_RuntimeError, nbd_get_error ());\n"; + pr " raise_exception ();\n"; pr " py_ret = NULL;\n"; pr " goto out;\n"; pr " }\n"; @@ -3917,6 +3946,9 @@ Read the libnbd(3) man page to find out how to use the API. import libnbdmod +# Reexport Error exc...
2019 Jun 28
1
[PATCH libnbd] python: Raise a custom exception containing error string and errno.
I spent a good few hours this morning trying to make this work and came up with the following patch. It's not quite right though. The exception I've created exists in the libnbdmod module (ie. the underlying C module that we use for the Python bindings). Ideally we'd define and throw an exception from the normal nbd module, but I couldn't work out how to do that. Probably
2019 Jun 28
0
[PATCH libnbd v3] python: Raise a custom exception containing error string and errno.
...rror); + return mod; } " @@ -3796,7 +3817,7 @@ let print_python_binding name { args; ret } = | RBool | RErr | RFd | RInt | RInt64 -> pr " if (ret == -1) {\n"; | RConstString | RString -> pr " if (ret == NULL) {\n"; ); - pr " PyErr_SetString (PyExc_RuntimeError, nbd_get_error ());\n"; + pr " raise_exception ();\n"; pr " py_ret = NULL;\n"; pr " goto out;\n"; pr " }\n"; @@ -3917,6 +3938,36 @@ Read the libnbd(3) man page to find out how to use the API. import libnbdmod +# Re-export Error e...
2019 Jun 28
3
[PATCH libnbd v3] python: Raise a custom exception containing error string and errno.
Following Eric's suggestions from v2, this adds .string, .errno and .__str__ properties. The .string property returns the error string. The .errno property returns the errno (from the errno module), or None. The __str__ property makes the exception nicely printable. Rich.
2019 Aug 11
4
[PATCH libnbd v2 0/3] python: Add test for doing asynch copy.
v1 was here: https://www.redhat.com/archives/libguestfs/2019-August/msg00103.html In v2 I've made several changes: - Fix Python callbacks so if they don't return something which is int-like, we assume they mean to return 0. - Add nbd.Buffer free() method. Read commit message in patch 2 to see what this is about. - Fixed the asynch copy test to deal with the unbelievably
2019 Aug 09
0
[PATCH libnbd 1/2] generator: Handle closure args (cbargs) specially.
...; 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; - pr " PyErr_SetString (PyExc_RuntimeError, \"PyList_Size failed\");\n"; - pr " return NULL;\n"; - pr " }\n"; - pr " %s = malloc (sizeof (uint32_t) * %s);\n" n len; - pr " if (%s == NULL) {\n" n; - pr " PyErr_NoMemory ();\n"; - pr &...
2010 Sep 09
2
[PATCH]: add libxl python binding
...MethodDef xl_methods[] = { { NULL } }; + +PyMODINIT_FUNC initxl(void) +{ + PyObject *m; + + if (PyType_Ready(&PyXlType) < 0) + return; + + m = Py_InitModule(PKG, xl_methods); + + if (m == NULL) + return; + + xl_error_obj = PyErr_NewException(PKG ".Error", PyExc_RuntimeError, NULL); + + Py_INCREF(&PyXlType); + PyModule_AddObject(m, CLS, (PyObject *)&PyXlType); + + Py_INCREF(xl_error_obj); + PyModule_AddObject(m, "Error", xl_error_obj); + + genwrap__init(m); +} + + +/* + * Local variables: + * c-indent-level: 4 + * c-basic-offset: 4 +...
2005 Sep 08
45
/proc/xen/xenbus supports watch?
Hi, Anybody (Christian?) could please tell me if we can get the support for registering watch with /proc/xen/xenbus? (..OK, I know that we will change it this /proc stuff to a device soon) So far we can only do read/write/rm. I really miss the xen watch feature. Many thanks, Hieu _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com
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.