Message306885
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). |
|
Date |
User |
Action |
Args |
2017-11-24 10:53:00 | vstinner | set | recipients:
+ vstinner, pitrou, jbakker |
2017-11-24 10:53:00 | vstinner | set | messageid: <1511520780.59.0.213398074469.issue32121@psf.upfronthosting.co.za> |
2017-11-24 10:53:00 | vstinner | link | issue32121 messages |
2017-11-24 10:53:00 | vstinner | create | |
|