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

后端 未结 7 1308
梦如初夏
梦如初夏 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:45

    You might also be interested in PEP-3134, which is implemented in python 3 and allows you to tack one exception/traceback onto an upstream exception.

    This isn't quite the same thing as modifying the traceback, but it would probably be the ideal way to convey the "short version" to library users while still having the "long version" available.

提交回复
热议问题