diff options
author | 2018-10-07 09:52:41 +0200 | |
---|---|---|
committer | 2019-10-22 20:10:52 +0200 | |
commit | d58d9f78ef0cdf68ae1439ef049bff7101e7f310 (patch) | |
tree | 0927881fab85ec8632e7f122df416380f3185b9f | |
parent | 022b1132d9c57e83e4fc76a165b2a478c0c151a8 (diff) | |
download | paludis-d58d9f78ef0cdf68ae1439ef049bff7101e7f310.tar.gz paludis-d58d9f78ef0cdf68ae1439ef049bff7101e7f310.tar.xz |
python: Normalize exceptions
The python 3 incompatible call of `file` in the python hook caused an
exception. Trying to get the traceback failed because the exception
isn't normalized:
13: [ RUN ] Hooker.Ordering
13: paludis@1565848332: [WARNING hook.python.traceback_failed] In thread ID '13623':
13: ... When triggering hook 'ordering':
13: ... When running hook 'hooker_TEST_dir/ordering/py_hook.py' for hook 'ordering':
13: ... When getting traceback
13: ... Hook 'hooker_TEST_dir/ordering/py_hook.py': _get_traceback(): traceback.format_exception failed
13: paludis@1565848332: [WARNING hook.python.failure] Hook 'hooker_TEST_dir/ordering/py_hook.py': running hook_run_ordering function failed: 'Getting traceback failed'
13: paludis@1565848332: [WARNING hook.python.failure] Hook 'hooker_TEST_dir/ordering/py_hook.py' failed unexpectedly: 'Traceback (most recent call last):
13: File "/usr/x86_64-pc-linux-gnu/lib/python3.7/traceback.py", line 121, in format_exception
13: type(value), value, tb, limit=limit).format(chain=chain))
13: File "/usr/x86_64-pc-linux-gnu/lib/python3.7/traceback.py", line 476, in __init__
13: if (exc_value and exc_value.__cause__ is not None
13: AttributeError: 'str' object has no attribute '__cause__'
13:
13: The above exception was the direct cause of the following exception:
13:
13: Traceback (most recent call last):
13: File "/home/marv/devel/paludis-worktrees/cross/python/paludis_output_wrapper.py", line 101, in restore_prefix
13: restore("both")
13: File "/home/marv/devel/paludis-worktrees/cross/python/paludis_output_wrapper.py", line 80, in restore
13: if len(stderr_cache):
13: SystemError: <built-in function len> returned a result with an error set'
13: ../paludis/hooker_TEST.cc:76: Failure
13: Expected equality of these values:
13: 0
13: result.max_exit_status()
13: Which is: 1
13: ../paludis/hooker_TEST.cc:83: Failure
13: Expected equality of these values:
13: "e\nc\nf\nd\nb\na\npy_hook\ng\ni\nh\nsohook\nk\nj\n"
13: line
13: Which is: "e\nc\nf\nd\nb\na\ng\ni\nh\nsohook\nk\nj\n"
13: With diff:
13: @@ -5,5 @@
13: b
13: a
13: -py_hook
13: g
13: i
13:
13: [ FAILED ] Hooker.Ordering (195 ms)
-rw-r--r-- | paludis/python_hooks.cc | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/paludis/python_hooks.cc b/paludis/python_hooks.cc index e47fc7a58..566bd1ddc 100644 --- a/paludis/python_hooks.cc +++ b/paludis/python_hooks.cc @@ -393,6 +393,7 @@ PyHookFile::_get_traceback() const PyObject * ptype, * pvalue, * ptraceback; PyErr_Fetch(&ptype, &pvalue, &ptraceback); + PyErr_NormalizeException(&ptype, &pvalue, &ptraceback); if (ptype == NULL) ptype = Py_None; |