New submission from Guido van Rossum:

The traceback module is driving me nuts.  It has some handy helpers to extract 
info about a traceback or a full stack without formatting them, but (a) these 
are _internal, and (b) they don't return the frame object as part of the 
information, so code that wants to do additional stuff (e.g. print the values 
of local variables) cannot use them. (I guess in a sense the two problems 
cancel each other out. :-)

Here's a proposed fix.  (I know it is lacking tests.)

It adds extract_tb_ex() and extract_stack_ex() functions that return a list of 
5-tuples filename, line number, function name, text, frame).

I'm also reworking the lowest-level internal function, 
_extract_tb_or_stack_iter(), to take an iterator instead of a starting point 
and a function to get the info and the next starting point.  The old design 
feels unpythonic to me -- the task at hand so clearly feels like it should wrap 
an iterator!

Finally, I'm adding some important info to a few docstrings: when the limit 
clips the number of frames, you get the *oldest* frames from a traceback, but 
the *newest* frames from a stack. That makes sense when you think about it, but 
I still think it's worth mentioning.

Feedback?

----------
messages: 198852
nosy: akuchling, benjamin.peterson, gvanrossum
priority: normal
severity: normal
status: open
title: Improvements to traceback module

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue19146>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to