search for: error_cstr

Displaying 5 results from an estimated 5 matches for "error_cstr".

2018 Aug 08
2
[PATCH nbdkit] python: Try harder to print the full traceback on error.
...ython/python.c +++ b/plugins/python/python.c @@ -129,27 +129,91 @@ python_to_string (PyObject *str) return NULL; } +/* This is the fallback in case we cannot get the full traceback. */ +static void +print_python_error (const char *callback, PyObject *error) +{ + PyObject *error_str; + char *error_cstr = NULL; + + error_str = PyObject_Str (error); + error_cstr = python_to_string (error_str); + nbdkit_error ("%s: %s: error: %s", + script, callback, + error_cstr ? error_cstr : "<unknown>"); + Py_DECREF (error_str); + free (error_cstr); +}...
2018 Aug 08
0
Re: [PATCH nbdkit] python: Try harder to print the full traceback on error.
...; @@ -129,27 +129,91 @@ python_to_string (PyObject *str) > return NULL; > } > > +/* This is the fallback in case we cannot get the full traceback. */ > +static void > +print_python_error (const char *callback, PyObject *error) > +{ > + PyObject *error_str; > + char *error_cstr = NULL; > + > + error_str = PyObject_Str (error); > + error_cstr = python_to_string (error_str); + nbdkit_error ("%s: %s: error: %s", > + script, callback, > + error_cstr ? error_cstr : "<unknown>"); > + Py_DECREF (error...
2018 Apr 05
1
Re: [PATCH nbdkit] python: Turn python exceptions into nbdkit errors properly.
...ure (const char *callback) > { > if (PyErr_Occurred ()) { > - nbdkit_error ("%s: callback failed: %s", script, callback); > - /* How to turn this into a string? XXX */ > - PyErr_Print (); > + PyObject *type, *error, *traceback, *error_str; > + char *error_cstr; > + > + /* Convert the Python exception to a string. > + * https://stackoverflow.com/a/1418703 > + * But forget about the traceback, it's very hard to print. > + * https://stackoverflow.com/q/1796510 > + */ > + PyErr_Fetch (&type, &error, &amp...
2018 Apr 05
4
[PATCH nbdkit] python: Turn python exceptions into nbdkit errors
Much more annoying that it needs to be, but I have tested it and it works on Python 2 & 3. Note this will not work on Python 3.0 - 3.2, but I guess we don't care about those versions. Rich.
2018 Apr 05
0
[PATCH nbdkit] python: Turn python exceptions into nbdkit errors properly.
...+} + static int check_python_failure (const char *callback) { if (PyErr_Occurred ()) { - nbdkit_error ("%s: callback failed: %s", script, callback); - /* How to turn this into a string? XXX */ - PyErr_Print (); + PyObject *type, *error, *traceback, *error_str; + char *error_cstr; + + /* Convert the Python exception to a string. + * https://stackoverflow.com/a/1418703 + * But forget about the traceback, it's very hard to print. + * https://stackoverflow.com/q/1796510 + */ + PyErr_Fetch (&type, &error, &traceback); + PyErr_NormalizeEx...