This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Refactor traceback.py to make TracebackException more extensible.
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: abrosimov.a.a
Priority: normal Keywords:

Created on 2021-09-09 22:41 by abrosimov.a.a, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg401528 - (view) Author: Anton Abrosimov (abrosimov.a.a) * Date: 2021-09-09 22:41
1. Move internal dependencies (`FrameSummary`, `StackSummary`) to class attributes. Reduce coupling.
2. Separate receiving, processing and presenting traceback information.
How to replace `repr` with `pformat` in `FrameSummary`?
def __init__(...):
    ...
    self.locals = {k: repr(v) for k, v in locals.items()} if locals else None
    ...
3. Move formatting templates to class attributes.
4. ...

Motivation:
1. For the sake of small changes to the view, you have to rewrite the entire `TracebackException` hierarchy. Or use string parsing.
2.1. During development, I want to see as much information as possible.
2.2. During production, displaying unnecessary information can lead to security problems.
2.3. In large projects, it is more convenient to use JSON for further processing in the system environment.

I have not found any PEPs describing `traceback.py`.
I can make a prototype of the changes if anyone is interested.
msg401529 - (view) Author: Anton Abrosimov (abrosimov.a.a) * Date: 2021-09-09 23:05
I think now is a good time for such a change. `FrameSummary`,` StackSummary` and `TracebackException` can be left backward compatible. And PEP 657 already breaks backward compatibility of output parsers.
History
Date User Action Args
2022-04-11 14:59:49adminsetgithub: 89321
2021-09-09 23:05:39abrosimov.a.asetmessages: + msg401529
2021-09-09 22:41:24abrosimov.a.acreate