]> granicus.if.org Git - python/commit
bpo-30579: Allow TracebackType creation and tb_next mutation from Python (GH-4793)
authorNathaniel J. Smith <njs@pobox.com>
Sun, 7 Jan 2018 13:30:18 +0000 (05:30 -0800)
committerNick Coghlan <ncoghlan@gmail.com>
Sun, 7 Jan 2018 13:30:18 +0000 (23:30 +1000)
commite46a8af450210ee5c7f0459ad6beddbc626ae60f
tree7d8abe4ccbec09008bec52d603446599feb84fda
parentd327ae6ba157fb5118df28a86975c5ca523f05e2
bpo-30579: Allow TracebackType creation and tb_next mutation from Python (GH-4793)

Third party projects may wish to hide their own internal machinery in
order to present more comprehensible tracebacks to end users
(e.g. Jinja2 and Trio both do this).

Previously such projects have had to rely on ctypes to do so:

  https://github.com/pallets/jinja/blob/fe3dadacdf4cf411d0a5b6bbd4d5234697a28af2/jinja2/debug.py#L345
  https://github.com/python-trio/trio/blob/1e86b1aee8c0c759f6f239ae53a05d0d3963c629/trio/_core/_multierror.py#L296

This provides a Python level API for creating and modifying real
Traceback objects, allowing tracebacks to be edited at runtime.

Patch by Nathaniel Smith.
Lib/test/test_raise.py
Misc/NEWS.d/next/Core and Builtins/2017-12-11-01-52-42.bpo-30579.X6cEzf.rst [new file with mode: 0644]
Python/clinic/traceback.c.h [new file with mode: 0644]
Python/traceback.c