bpo-33256: Replace angle brackets around python object repr to display it in html (GH-6442)
(cherry picked from commit 7d68bfa826
)
Co-authored-by: sblondon <sblondon@users.noreply.github.com>
This commit is contained in:
parent
a26a297b4b
commit
ef91552cfb
|
@ -124,7 +124,7 @@ function calls leading up to the error, in the order they occurred.</p>'''
|
||||||
args, varargs, varkw, locals = inspect.getargvalues(frame)
|
args, varargs, varkw, locals = inspect.getargvalues(frame)
|
||||||
call = ''
|
call = ''
|
||||||
if func != '?':
|
if func != '?':
|
||||||
call = 'in ' + strong(func) + \
|
call = 'in ' + strong(pydoc.html.escape(func)) + \
|
||||||
inspect.formatargvalues(args, varargs, varkw, locals,
|
inspect.formatargvalues(args, varargs, varkw, locals,
|
||||||
formatvalue=lambda value: '=' + pydoc.html.repr(value))
|
formatvalue=lambda value: '=' + pydoc.html.repr(value))
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ class Hook:
|
||||||
|
|
||||||
if self.display:
|
if self.display:
|
||||||
if plain:
|
if plain:
|
||||||
doc = doc.replace('&', '&').replace('<', '<')
|
doc = pydoc.html.escape(doc)
|
||||||
self.file.write('<pre>' + doc + '</pre>\n')
|
self.file.write('<pre>' + doc + '</pre>\n')
|
||||||
else:
|
else:
|
||||||
self.file.write(doc + '\n')
|
self.file.write(doc + '\n')
|
||||||
|
|
|
@ -45,6 +45,7 @@ class TestCgitb(unittest.TestCase):
|
||||||
out = out.decode(sys.getfilesystemencoding())
|
out = out.decode(sys.getfilesystemencoding())
|
||||||
self.assertIn("ValueError", out)
|
self.assertIn("ValueError", out)
|
||||||
self.assertIn("Hello World", out)
|
self.assertIn("Hello World", out)
|
||||||
|
self.assertIn("<strong><module></strong>", out)
|
||||||
# By default we emit HTML markup.
|
# By default we emit HTML markup.
|
||||||
self.assertIn('<p>', out)
|
self.assertIn('<p>', out)
|
||||||
self.assertIn('</p>', out)
|
self.assertIn('</p>', out)
|
||||||
|
|
|
@ -154,6 +154,7 @@ Mike Bland
|
||||||
Martin Bless
|
Martin Bless
|
||||||
Pablo Bleyer
|
Pablo Bleyer
|
||||||
Erik van Blokland
|
Erik van Blokland
|
||||||
|
Stéphane Blondon
|
||||||
Eric Blossom
|
Eric Blossom
|
||||||
Sergey Bobrov
|
Sergey Bobrov
|
||||||
Finn Bock
|
Finn Bock
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fix display of ``<module>`` call in the html produced by ``cgitb.html()``. Patch by Stéphane Blondon.
|
Loading…
Reference in New Issue