[Python-ideas] feature to make traceback objects usable without references to frame locals and globals

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Jun 26 10:23:52 CEST 2010


ghazel at gmail.com wrote:

> I'm interested in a feature which allows users to discard the locals
> and globals references from frames held by a traceback object.

I'd like to take this further and remove the need for
traceback objects to refer to a frame object at all.
The standard traceback printout only needs two pieces of
information from the traceback, the file name and line
number.

The line number is already present in the traceback
object. All it would take is the addition of a file name
attribute to the traceback object, and the frame reference
could be made optional.

This would be a big help for Pyrex and Cython, which
currently have to create entire dummy frame objects in order
to add entries to the traceback. Not only is this tedious
and inefficient, it ties them to internal details of the
frame object that are vulnerable to change. It would be
much nicer to have a simple API function such as

   PyTraceback_AddEntry(filename, lineno)

to add a frameless traceback object.

-- 
Greg



More information about the Python-ideas mailing list