[Python-ideas] feature to make traceback objects usable without references to frame locals and globals
tjreedy at udel.edu
Tue Jun 29 03:26:52 CEST 2010
On 6/28/2010 8:39 AM, Antoine Pitrou wrote:
> However, as the OP argued, most often you need the traceback in order
> to display file names and line numbers, but you don't need the attached
> variables (locals and globals).
It then seems to me that one should extract the file name and line
number info one wants to save before exiting the exception clause and
let the traceback exception and traceback go on exit. Is a library
function needed to make extraction easier?
Perhaps this "The reason for this [deletion on exit] is that with the
traceback attached to them, exceptions will form a reference cycle with
the stack frame, keeping all locals in that frame alive until the next
garbage collection occurs." could be strengthened into a better warning
that this "That means that you have to assign the exception to a
different name if you want to be able to refer to it after the except
clause. " may really, really not be a good idea.
Terry Jan Reedy
More information about the Python-ideas