Customize backtrace logic?
quark-zju opened this issue · 0 comments
quark-zju commented
In a Rust / Python program, the Rust backtrace might contain PyEval_EvalFrameEx
frames. It indicates Python is involved, but not which Python function. It'd be nice to be able to annotate those PyEval_EvalFrameEx
frames with the actual Python function names.
By allowing a customized "backtrace" logic, such Python / Rust application might:
- Use PEP 523 to insert a custom
PyEval_EvalFrameEx
wrapper that tracks what native frames associate with what Python functions. - Provide a Rust
backtrace
wrapper that translates native frames back to Python functions using the above information. - Register the customized
backtrace
logic toanyhow
.
This might be alternatively implemented by not changing anyhow
but updating the "display" logic to look at the Error::backtrace
and do some post-processing. But that might be annoying if there are deeply nested errors, and backtrace
is only available in some cases.