[Python-Dev] Patch review: [ 1098732 ] Enhance tracebacks and stack traces with vars

"Martin v. Löwis" martin at v.loewis.de
Thu Feb 10 00:21:08 CET 2005


Phillip J. Eby wrote:
> Yes, but not as a default behavior.  Many people already consider the 
> fact that tracebacks display file paths to be a potential security 
> problem.  If anything, the default traceback display should have less 
> information, not more.  (E.g., display module __name__ instead of the 
> code's __file__).

Notice that this patch does not change the exception printing behaviour
of Python at all. It just changes the implementation of
traceback.print_exception, so it only affects code that actually uses
this function. Furthermore, it only affects code that uses this function
and is *changed* to supply the argument True for print_args.

> Also note that the stdlib already has a cgitb module that does this sort 
> of display for CGI scripts, so the technique isn't new, and cgitb 
> provides a good example for people to create their own advanced 
> traceback formatters with.

Sure. However, if this is frequently needed (outside the context of
CGI), it would sure be helpful if the traceback module supported it.

> If there were another command line option added to Python for this, I'd 
> personally prefer it be an option to enter the debugger when a terminal 
> traceback is printed.  Currently, I use 'python -i' so that I get an 
> interpreter prompt, then use 'import pdb; pdb.pm()' to enter the 
> debugger at the point where the error occurred.

With the patch, you would have to add an explicit try/except into
your code, to supply True for print_args (or set a sys.excepthook,
as Skip suggests in his patch readme).

Regards,
Martin


More information about the Python-Dev mailing list