[PATCH nbdkit] python: Print readable tracebacks
We used traceback.format_exception, returning traceback lines. Join the lines to make the tracebacks more readable. Here is an example traceback: $ ./nbdkit -f -v python tests/python-exception.py ... nbdkit: debug: python: config_complete nbdkit: error: tests/python-exception.py: config_complete: error: Traceback (most recent call last): File "tests/python-exception.py", line 51, in config_complete raise RuntimeError("this is the test string") RuntimeError: this is the test string --- plugins/python/python.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/python/python.c b/plugins/python/python.c index 148097f..71fa2e3 100644 --- a/plugins/python/python.c +++ b/plugins/python/python.c @@ -167,7 +167,7 @@ print_python_traceback (const char *callback, type, error, traceback, NULL); if (rv == NULL) return -1; - traceback_str = PyObject_Str (rv); + traceback_str = PyUnicode_Join (NULL, rv); Py_DECREF (rv); traceback_cstr = python_to_string (traceback_str); if (traceback_cstr == NULL) { -- 2.21.0
On Sat, Nov 23, 2019 at 05:06:41AM +0200, Nir Soffer wrote:
We used traceback.format_exception, returning traceback lines. Join the lines to make the tracebacks more readable.
Here is an example traceback:
$ ./nbdkit -f -v python tests/python-exception.py ... nbdkit: debug: python: config_complete nbdkit: error: tests/python-exception.py: config_complete: error: Traceback (most recent call last): File "tests/python-exception.py", line 51, in config_complete raise RuntimeError("this is the test string") RuntimeError: this is the test string --- plugins/python/python.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/python/python.c b/plugins/python/python.c index 148097f..71fa2e3 100644 --- a/plugins/python/python.c +++ b/plugins/python/python.c @@ -167,7 +167,7 @@ print_python_traceback (const char *callback, type, error, traceback, NULL); if (rv == NULL) return -1; - traceback_str = PyObject_Str (rv); + traceback_str = PyUnicode_Join (NULL, rv); Py_DECREF (rv); traceback_cstr = python_to_string (traceback_str); if (traceback_cstr == NULL) {
ACK and pushed, thanks. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
participants (2)
-
Nir Soffer -
Richard W.M. Jones