[issue4643] cgitb.html fails if getattr call raises exception
Irit Katriel
report at bugs.python.org
Sun Nov 15 13:52:40 EST 2020
Irit Katriel <iritkatriel at yahoo.com> added the comment:
The issue still occurs in 3.10. Python 3 version of the script:
import cgitb
class WeirdObject(object):
def __getattr__(self, attr):
if attr == 'a':
return 'the letter a'
elif attr == 'b':
return str(slf) # Intentional NameError
raise AttributeError(attr)
try:
weird = WeirdObject()
print('A:', weird.a)
print('B:', weird.b)
print('C:', weird.c)
except Exception as e:
import sys
print('\nSomething went wrong - attempting to generate HTML stack trace.')
try:
html_text = cgitb.html(sys.exc_info())
except:
print('Error generating HTML stack trace!')
raise
else:
print('Here is stack trace in HTML:\n', html_text)
----------
nosy: +iritkatriel
versions: +Python 3.10, Python 3.8, Python 3.9 -Python 2.7, Python 3.2, Python 3.3, Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue4643>
_______________________________________
More information about the Python-bugs-list
mailing list