This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: make error reporting better like cgi
Type: enhancement Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: Nosy List: hfastedge, mwh, skip.montanaro
Priority: normal Keywords:

Created on 2002-12-16 11:33 by hfastedge, last changed 2022-04-10 16:06 by admin. This issue is now closed.

Messages (6)
msg13619 - (view) Author: Hunter Peress (hfastedge) Date: 2002-12-16 11:33
do something bad in something that uses cgitb, it will
show you actual values of the variables at that point
in the error message....and a host of useful info.

I think this should be done normally as well.
msg13620 - (view) Author: Hunter Peress (hfastedge) Date: 2003-01-23 23:20
Logged In: YES 
user_id=479934

HOW TO REPRODUCE:

We are going to test a basic piece of logic. In normal
interpreter (from cmdline), and in cgi mode. We will see
just how different the error reporting is:

<b>FIRST the basic LOGIC:
l=[1,2,3,4,5]
for i in range(len(l)):
    print i,l[i],l ; del l[i]

Next implement it in CGI:
#!/usr/bin/python2.2
import sys,commands,os,re,string,cgi,cgitb
cgitb.enable(1)
print "Content-type: text/html\n\n"
LOGIC GOES HERE

NOW Observe how nice the error is:
 /home/hperes/public_html/cgi-bin/cgiShow.cgi
    4 print "Content-type: text/html\n\n"
    5 print "HI"
    6 l=[1,2,3,4,5]
    7 for i in range(len(l)):
    8     print i,l[i],l ; del l[i]
i = 3, l = [2, 4]

IndexError: list index out of range
      __doc__ = 'Sequence index out of range.'
      __getitem__ = <bound method IndexError.__getitem__ of
<exceptions.IndexError instance at 0x8185c14>>
      __init__ = <bound method IndexError.__init__ of
<exceptions.IndexError instance at 0x8185c14>>
      __module__ = 'exceptions'
      __str__ = <bound method IndexError.__str__ of
<exceptions.IndexError instance at 0x8185c14>>
      args = ('list index out of range',) 

See how you can see the values of all the variables on the
line??


Next implement it in cmdline:
0 1 [1, 2, 3, 4, 5]
1 3 [2, 3, 4, 5]
2 5 [2, 4, 5]
3
Traceback (most recent call last):
  File "s", line 5, in ?
    print i,l[i],l ; del l[i]
IndexError: list index out of range


See how much more useless that is?
msg13621 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2003-01-24 17:17
Logged In: YES 
user_id=44345

Please don't needlessly boost priorities.  This is hardly of highest priority (it doesn't crash the interpreter, for example).

The issue of invoking cgitb functionality automatically was discussed at length when the module was first added to the system.  It was decided that the possibility for breakage was too great.  After all, other people have almost certainly had to address this problem in their own cgi scripts.  Invoking cgitb may thwart those mechanisms, or worse, present clues about
the internal workings of the system which would give bad guys help 
breaking into systems.

In short, feel free to import cgitb into your own cgi scripts, but don't
force others to use it if they choose not to.
msg13622 - (view) Author: Hunter Peress (hfastedge) Date: 2003-01-24 17:36
Logged In: YES 
user_id=479934

montanaro: FIRST, I put the priority on 9 because I finally
added a huge chunk of code to show what I was talking about.
Given this , and since this bug was in the system for so
long, I flagged it to 9, solely so that it would reget some
needed attention, and then  expecting one of the powers that
be to bring it back down to normal.

WELL: not only did you not do this. You closed the bug, AND
you completely did not comprehend what its point is.

Quickly: i show the the STRENGTHS of  the error reporting
mechanism in cgitb, and this bug suggests that some (if not
all) features should be implemented in the normal interpreter.

Most useful is the fact that you get to see values of all
variables on the line causing error.

As you can see, i reflagged this to 9 solely to get your
attention. please bring it back down to 5 when u read this.
msg13623 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2003-01-24 17:46
Logged In: YES 
user_id=6656

OK, but we don't use priorities like that in this project. 
All it acheives is winding people up.
msg13624 - (view) Author: Skip Montanaro (skip.montanaro) * (Python triager) Date: 2003-06-16 18:35
Logged In: YES 
user_id=44345

duplicate of 569574
History
Date User Action Args
2022-04-10 16:06:02adminsetgithub: 37616
2002-12-16 11:33:39hfastedgecreate