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: cgitb failures
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: ajaksu2, ethan.furman, iritkatriel, jhylton, rgbecker, wam
Priority: normal Keywords: easy, patch

Created on 2004-10-14 22:23 by rgbecker, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
cgitbbug.py rgbecker, 2004-10-14 22:23 Trivial exciter for the problems
bugfix000.patch rgbecker, 2004-10-14 23:33 Patch against 2.4a3 to fix 1047397
terror.py rgbecker, 2004-11-07 12:11 erroring value and usage
bugfix001.patch rgbecker, 2004-11-07 14:01 bugfix000.patch forgot </em> in a message
bugfix002.patch rgbecker, 2004-11-07 14:04 -4 lines, but more complex patch same end
bugfix003.patch rgbecker, 2014-07-19 13:10 patch against cgitb.py in 3.4.1
Pull Requests
URL Status Linked Edit
PR 15094 closed Rhodri James, 2019-08-03 14:37
Messages (8)
msg22695 - (view) Author: Robin Becker (rgbecker) Date: 2004-10-14 22:23
cgitb fails when evaluating various reprs/getattrs. The bug
demonstrator is cgitbbug.py. Below is the run output
for two bugs. Fixes are possible by putting try: except
around various evaluations. Although the test is
artificial we found these could happen in real code.

This is with 2.4a3 Windows XP

Sample output

C:\Python24>.\python \tmp\cgitbbug.py repr1
2.4a3 (#56, Sep  2 2004, 20:50:21) [MSC v.1310 32 bit
(Intel)]
Traceback (most recent call last):
  File "\tmp\cgitbbug.py", line 36, in ?
    print cgitb.html(sys.exc_info(),context=3)
  File "C:\python24\lib\cgitb.py", line 155, in html
    dump.append('%s = %s' % (name,
pydoc.html.repr(value)))
  File "C:\python24\lib\pydoc.py", line 352, in repr
    return Repr.repr(self, object)
  File "C:\python24\lib\repr.py", line 24, in repr
    return self.repr1(x, self.maxlevel)
  File "C:\python24\lib\pydoc.py", line 359, in repr1
    return self.escape(cram(stripid(repr(x)),
self.maxother))
  File "\tmp\cgitbbug.py", line 12, in __repr__
    if self._mad=='repr1': raise ValueError('repr1
madness')
ValueError: repr1 madness

C:\Python24>.\python \tmp\cgitbbug.py getattr1
2.4a3 (#56, Sep  2 2004, 20:50:21) [MSC v.1310 32 bit
(Intel)]
Traceback (most recent call last):
  File "\tmp\cgitbbug.py", line 36, in ?
    print cgitb.html(sys.exc_info(),context=3)
  File "C:\python24\lib\cgitb.py", line 129, in html
    vars = scanvars(reader, frame, locals)
  File "C:\python24\lib\cgitb.py", line 83, in scanvars
    value = getattr(parent, token, __UNDEF__)
  File "\tmp\cgitbbug.py", line 16, in __getattr__
    if self._mad=='getattr1': raise
ValueError('getattr1 madness')
ValueError: getattr1 madness

C:\Python24>
msg22696 - (view) Author: Robin Becker (rgbecker) Date: 2004-10-14 23:33
Logged In: YES 
user_id=6946

Bug fix added
msg22697 - (view) Author: Jeremy Hylton (jhylton) (Python triager) Date: 2004-11-07 14:32
Logged In: YES 
user_id=31392

The formatting of this patch is wrong.  There is a long line
(>80 chars) and missing whitespace around commas, operators,
etc.
msg82098 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-02-14 18:20
Confirmed on trunk.
msg114382 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-08-19 17:39
Anyone interested in running with this as it's still a problem in all versions?
msg223448 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014-07-18 22:51
The output now is

c:\Users\Mark\PythonIssues>cgitbbug.py getattr1
3.4.1 (v3.4.1:c0e311e010fc, May 18 2014, 10:38:22) [MSC v.1600 32 bit (Intel)]
Traceback (most recent call last):
  File "C:\Users\Mark\PythonIssues\cgitbbug.py", line 34, in <module>
    d.h('aaa')
  File "C:\Users\Mark\PythonIssues\cgitbbug.py", line 23, in _f
    raiseError()
  File "C:\Users\Mark\PythonIssues\cgitbbug.py", line 3, in raiseError
    raise ValueError('original error')
ValueError: original error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Mark\PythonIssues\cgitbbug.py", line 36, in <module>
    print(cgitb.html(sys.exc_info(),context=3))
  File "c:\python34\lib\cgitb.py", line 136, in html
    vars = scanvars(reader, frame, locals)
  File "c:\python34\lib\cgitb.py", line 88, in scanvars
    value = getattr(parent, token, __UNDEF__)
  File "C:\Users\Mark\PythonIssues\cgitbbug.py", line 16, in __getattr__
    if self._mad=='getattr1': raise ValueError('getattr1 madness')
ValueError: getattr1 madness

Thus the madness has been fixed and this can be closed as "out of date".
msg223464 - (view) Author: Robin Becker (rgbecker) Date: 2014-07-19 13:10
I'll repeat the post I made to BreamoreBoy regarding this bug:

"re: http://bugs.python.org/issue1047397

this bug is now 10 years old. I'm not sure why it's to be considered
closed because the original intent of the bug report was that the html
output of the cgitb module could be confused and errors during
evaluation could make the html output fail. So far as I can tell by
modifying the original cgitbbug.py to run under python 3.4.1 it still
fails to correctly produce html when a bug occurs in cgitb.html.
Producing a more reasonable traceback is certainly a step forward, but
I think that has been true since at least 3.1. The whole point of
cgitb is to produce something reasonable for an html consumer."

I have re-created the original 002 patch with mods for python 3.4.1. It's a bit of a shame that this wasn't fixed 10 years ago. Hopefully any style pedants will find this patch more acceptable. Personally I don't think style errors should prevent a working fix from being adopted. I would have just fixed the fix style and carped afterwards.
msg415057 - (view) Author: Irit Katriel (iritkatriel) * (Python committer) Date: 2022-03-13 17:34
cgi/cgitb are deprecated as per PEP 594, so there won't be further enhancements to them.
History
Date User Action Args
2022-04-11 14:56:07adminsetgithub: 41022
2022-03-13 17:34:55iritkatrielsetstatus: open -> closed

nosy: + iritkatriel
messages: + msg415057

resolution: wont fix
stage: patch review -> resolved
2021-01-02 19:28:42iritkatriellinkissue4643 superseder
2020-07-20 20:51:25Rhodri Jamessetnosy: - Rhodri James
2019-08-03 14:37:34Rhodri Jamessetpull_requests: + pull_request14841
2019-07-29 23:18:52ethan.furmansetnosy: + ethan.furman, Rhodri James
2019-04-26 20:04:58BreamoreBoysetnosy: - BreamoreBoy
2014-07-20 06:39:30berker.peksagsetversions: + Python 3.4, Python 3.5, - Python 3.2, Python 3.3
2014-07-19 13:10:11rgbeckersetfiles: + bugfix003.patch

messages: + msg223464
2014-07-18 22:51:17BreamoreBoysetnosy: + BreamoreBoy
messages: + msg223448
2011-11-19 14:00:44ezio.melottisetnosy: - BreamoreBoy

versions: + Python 3.3, - Python 3.1
2010-08-19 17:39:28BreamoreBoysetversions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6
nosy: + BreamoreBoy

messages: + msg114382

stage: test needed -> patch review
2010-08-02 04:03:32wamsetnosy: + wam
2009-02-14 18:20:02ajaksu2setversions: + Python 2.6, - Python 2.4
nosy: + ajaksu2
messages: + msg82098
keywords: + patch, easy
type: behavior
stage: test needed
2004-10-14 22:23:50rgbeckercreate