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.

Author ulope
Recipients fhackdroid, iritkatriel, r.david.murray, ulope
Date 2021-09-16.17:41:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1631814115.67.0.895735499843.issue33809@roundup.psfhosted.org>
In-reply-to
Content
> If we copy all the params from TracebackException (and it will be all params, why only this one?)

Why expose the internal machinery at all?
If all additional parameters (and unless I'm miscounting we're talking about 2) were exposed on the convenience functions why add to the developers mental load with the underlying implementation?

> more documentation and a higher cognitive load for someone reading the documentation to learn the API.

I would agree if the API in question was ergonomic and the documentation easy to read in the first place. I think neither is true for the traceback module and its documentation.

Another example from today where I helped a coworker who was unable to figure out on his own how to print the current stack with locals:


  from traceback import StackSummary, walk_stack
  
  print("".join(StackSummary.extract(walk_stack(None), capture_locals=True).format()))

There are multiple things that make this API non-intuitive:
- Why does walk_stack() need an explicit None argument?
- Why is StackSummary created via the extract() classmethod instead of having a regular __init__?
- Why can't extract() be smart if no iterator is passed and figure out on it's own if we're in an exception context or not and call walk_stack / walk_tb accordingly?
- Why is the result a list if each item can contain multiple internal newlines?
History
Date User Action Args
2021-09-16 17:41:55ulopesetrecipients: + ulope, r.david.murray, fhackdroid, iritkatriel
2021-09-16 17:41:55ulopesetmessageid: <1631814115.67.0.895735499843.issue33809@roundup.psfhosted.org>
2021-09-16 17:41:55ulopelinkissue33809 messages
2021-09-16 17:41:55ulopecreate