From 28bad9753dc88b40854be58e5177fb893539ee61 Mon Sep 17 00:00:00 2001 From: John Rouillard Date: Tue, 14 May 2024 21:27:28 -0400 Subject: [PATCH] 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. --- CHANGES.txt | 3 +++ roundup/cgi/cgitb.py | 16 ++++++++++++---- test/test_misc.py | 2 +- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 8a2d3c4e..0fd66dfd 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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: diff --git a/roundup/cgi/cgitb.py b/roundup/cgi/cgitb.py index 3246f0b9..a4a14f7f 100644 --- a/roundup/cgi/cgitb.py +++ b/roundup/cgi/cgitb.py @@ -127,10 +127,18 @@ def html(context=5, i18n=None): if type(etype) is type: etype = etype.__name__ pyver = 'Python ' + sys.version.split()[0] + '
' + sys.executable - head = pydoc.html.heading( - _('%(exc_type)s: %(exc_value)s') - % {'exc_type': etype, 'exc_value': evalue}, - '#ffffff', '#777777', pyver) + + if sys.version_info[0:2] >= (3,11): + head = pydoc.html.heading( + _('%(exc_type)s: ' + '%(exc_value)s') + % {'exc_type': etype, 'exc_value': evalue}, pyver) + else: + head = pydoc.html.heading( + _('%(exc_type)s: ' + '%(exc_value)s') + % {'exc_type': etype, 'exc_value': evalue}, + '#ffffff', '#777777', pyver) head = head + (_('

A problem occurred while running a Python script. ' 'Here is the sequence of function calls leading up to ' diff --git a/test/test_misc.py b/test/test_misc.py index 579ed249..fedecde5 100644 --- a/test/test_misc.py +++ b/test/test_misc.py @@ -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.