Skip to content

Commit 28bad97

Browse files
committed
issue2551350 - Python changes for 3.12 with roundup 2.3.0 cgitb.py
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.
1 parent 44321d1 commit 28bad97

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ Fixed:
142142
option is off when the setting is missing from
143143
detectors/config.ini. Other templates do not implement this option.
144144
(John Rouillard)
145+
- issue2551350 - Python changes for 3.12 with roundup 2.3.0. Fixes for
146+
cgitb.py crash due to pydoc.html.header() signature change. (Patch
147+
by Andrew (kragacles), applied John Rouillard)
145148

146149
Features:
147150

roundup/cgi/cgitb.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,18 @@ def html(context=5, i18n=None):
127127
if type(etype) is type:
128128
etype = etype.__name__
129129
pyver = 'Python ' + sys.version.split()[0] + '<br>' + sys.executable
130-
head = pydoc.html.heading(
131-
_('<font size=+1><strong>%(exc_type)s</strong>: %(exc_value)s</font>')
132-
% {'exc_type': etype, 'exc_value': evalue},
133-
'#ffffff', '#777777', pyver)
130+
131+
if sys.version_info[0:2] >= (3,11):
132+
head = pydoc.html.heading(
133+
_('<font size=+1><strong>%(exc_type)s</strong>: '
134+
'%(exc_value)s</font>')
135+
% {'exc_type': etype, 'exc_value': evalue}, pyver)
136+
else:
137+
head = pydoc.html.heading(
138+
_('<font size=+1><strong>%(exc_type)s</strong>: '
139+
'%(exc_value)s</font>')
140+
% {'exc_type': etype, 'exc_value': evalue},
141+
'#ffffff', '#777777', pyver)
134142

135143
head = head + (_('<p>A problem occurred while running a Python script. '
136144
'Here is the sequence of function calls leading up to '

test/test_misc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def test_pt_html(self):
223223
else:
224224
self.assertEqual(expected2, p)
225225

226-
def notest_html(self):
226+
def test_html(self):
227227
""" templating error """
228228
# enabiling this will cause the test to fail as the variable
229229
# is included in the live output but not in expected.

0 commit comments

Comments
 (0)