How can I modify a Python traceback object when raising an exception?

后端 未结 7 1321
梦如初夏
梦如初夏 2020-11-29 09:56

I\'m working on a Python library used by third-party developers to write extensions for our core application.

I\'d like to know if it\'s possible to modify the trace

7条回答
  •  误落风尘
    2020-11-29 10:25

    Take a look at what jinja2 does here:

    https://github.com/mitsuhiko/jinja2/blob/5b498453b5898257b2287f14ef6c363799f1405a/jinja2/debug.py

    It's ugly, but it seems to do what you need done. I won't copy-paste the example here because it's long.

提交回复
热议问题