Skip to content

Commit

Permalink
issue2551350 - Python changes for 3.12 with roundup 2.3.0 cgitb.py
Browse files Browse the repository at this point in the history
Fix change in pydoc.html.header() signature. It dropped foreground and
background color arguments in 3.11 and newer.

Also enable test code for the html function.
  • Loading branch information
rouilj committed May 15, 2024
1 parent 44321d1 commit 28bad97
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ Fixed:
option is off when the setting is missing from
detectors/config.ini. Other templates do not implement this option.
(John Rouillard)
- issue2551350 - Python changes for 3.12 with roundup 2.3.0. Fixes for
cgitb.py crash due to pydoc.html.header() signature change. (Patch
by Andrew (kragacles), applied John Rouillard)

Features:

Expand Down
16 changes: 12 additions & 4 deletions roundup/cgi/cgitb.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,18 @@ def html(context=5, i18n=None):
if type(etype) is type:
etype = etype.__name__
pyver = 'Python ' + sys.version.split()[0] + '<br>' + sys.executable
head = pydoc.html.heading(
_('<font size=+1><strong>%(exc_type)s</strong>: %(exc_value)s</font>')
% {'exc_type': etype, 'exc_value': evalue},
'#ffffff', '#777777', pyver)

if sys.version_info[0:2] >= (3,11):
head = pydoc.html.heading(
_('<font size=+1><strong>%(exc_type)s</strong>: '
'%(exc_value)s</font>')
% {'exc_type': etype, 'exc_value': evalue}, pyver)
else:
head = pydoc.html.heading(
_('<font size=+1><strong>%(exc_type)s</strong>: '
'%(exc_value)s</font>')
% {'exc_type': etype, 'exc_value': evalue},
'#ffffff', '#777777', pyver)

head = head + (_('<p>A problem occurred while running a Python script. '
'Here is the sequence of function calls leading up to '
Expand Down
2 changes: 1 addition & 1 deletion test/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def test_pt_html(self):
else:
self.assertEqual(expected2, p)

def notest_html(self):
def test_html(self):
""" templating error """
# enabiling this will cause the test to fail as the variable
# is included in the live output but not in expected.
Expand Down

0 comments on commit 28bad97

Please sign in to comment.