STINNER Victor <[email protected]> added the comment:
tracemalloc.Traceback contains "raw" data from the C _tracemalloc module. But
since we are at Python level, we are free to change how data is rendered to
user.
Since Antoine Pitrou was surprised by the current frame order in
Traceback.format() ("This is not intuitive since ordinary Python tracebacks are
displayed in "most recent call last" order"), what do you think of adding a new
parameter but also **reverse frames by default**?
Maybe we can go further and even reverse frames in Traceback constructor? This
is a backward incompatible change, but I don't think that a lot of code in the
wild uses the tracemalloc *API*.
About the parameter name: I'm ok with "reverse". *But* if we reverse by
default, the "reverse" name can be confusing. Maybe we can use a less confusing
name like "most_recent_last=True" (or "most_recent_first=False")?
--
Note: The faulthandler module also dumps starting with the "(most recent call
first)", but I don't want to change that. It's for technical reason:
faulthandler is called when something really bad happens and so Python internal
structures may be corrupted. Moreover, frames is a single chained list, it's
hard to iterate over them in the backward order (especially in faulthandler
code where heap memory allocations are denied).
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue32121>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com