Skip to content

Customize backtrace logic? #328

Open
@quark-zju

Description

@quark-zju

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 to anyhow.

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions