[issue32121] tracemalloc.Traceback.format() should have an option to reverse the traceback

2017-11-29 Thread STINNER Victor

STINNER Victor  added the comment:

Jesse Bakker implemented all requested changes, I merged his PR. Well done, 
Jesse!

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32121] tracemalloc.Traceback.format() should have an option to reverse the traceback

2017-11-29 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset 706e10b186992e086e661a62d2c8ec9588525b31 by Victor Stinner 
(Jesse-Bakker) in branch 'master':
bpo-32121: Add most_recent_first parameter to tracemalloc.Traceback.format 
(#4534)
https://github.com/python/cpython/commit/706e10b186992e086e661a62d2c8ec9588525b31


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32121] tracemalloc.Traceback.format() should have an option to reverse the traceback

2017-11-24 Thread STINNER Victor

STINNER Victor  added the comment:

Serhiy:
> While we are here, what if make a negative limit truncating from the opposite 
> side, as in the traceback module?

Why not. I'm not opposed to that :-)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32121] tracemalloc.Traceback.format() should have an option to reverse the traceback

2017-11-24 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

While we are here, what if make a negative limit truncating from the opposite 
side, as in the traceback module?

--
nosy: +serhiy.storchaka

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32121] tracemalloc.Traceback.format() should have an option to reverse the traceback

2017-11-24 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> what do you think of adding a new parameter but also **reverse frames by 
> default**?

This would be fine with me.  I didn't want to suggest it because it would break 
compatibility but obviously I find the current behaviour annoying :-)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32121] tracemalloc.Traceback.format() should have an option to reverse the traceback

2017-11-24 Thread STINNER Victor

STINNER Victor  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 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32121] tracemalloc.Traceback.format() should have an option to reverse the traceback

2017-11-23 Thread Jesse Bakker

Jesse Bakker  added the comment:

I can work on this if you want. Can have a PR ready in a few minutes.

--
nosy: +Jesse Bakker

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32121] tracemalloc.Traceback.format() should have an option to reverse the traceback

2017-11-23 Thread Jesse Bakker

Change by Jesse Bakker :


--
keywords: +patch
pull_requests: +4470
stage: needs patch -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32121] tracemalloc.Traceback.format() should have an option to reverse the traceback

2017-11-23 Thread STINNER Victor

STINNER Victor  added the comment:

The option seems reasonable. Would you like to work on a pull request?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32121] tracemalloc.Traceback.format() should have an option to reverse the traceback

2017-11-23 Thread Antoine Pitrou

New submission from Antoine Pitrou :

Right now tracemalloc.Traceback.format() returns the frames in "most recent 
call first" order.  This is not intuitive since ordinary Python tracebacks are 
displayed in "most recent call last" order.  It would be nice to add a 
`reverse` argument to change that.

--
components: Library (Lib)
messages: 306856
nosy: pitrou, vstinner
priority: normal
severity: normal
stage: needs patch
status: open
title: tracemalloc.Traceback.format() should have an option to reverse the 
traceback
type: enhancement
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com