bpo-33256: Replace angle brackets around python object repr to display it in html (GH-6442)

This commit is contained in:
sblondon 2018-04-29 19:48:33 +02:00 committed by Serhiy Storchaka
parent 70af06cdc4
commit 7d68bfa826
4 changed files with 5 additions and 2 deletions

View file

@ -124,7 +124,7 @@ def html(einfo, context=5):
args, varargs, varkw, locals = inspect.getargvalues(frame)
call = ''
if func != '?':
call = 'in ' + strong(func) + \
call = 'in ' + strong(pydoc.html.escape(func)) + \
inspect.formatargvalues(args, varargs, varkw, locals,
formatvalue=lambda value: '=' + pydoc.html.repr(value))
@ -282,7 +282,7 @@ def handle(self, info=None):
if self.display:
if plain:
doc = doc.replace('&', '&amp;').replace('<', '&lt;')
doc = pydoc.html.escape(doc)
self.file.write('<pre>' + doc + '</pre>\n')
else:
self.file.write(doc + '\n')

View file

@ -45,6 +45,7 @@ def test_syshook_no_logdir_default_format(self):
out = out.decode(sys.getfilesystemencoding())
self.assertIn("ValueError", out)
self.assertIn("Hello World", out)
self.assertIn("<strong>&lt;module&gt;</strong>", out)
# By default we emit HTML markup.
self.assertIn('<p>', out)
self.assertIn('</p>', out)

View file

@ -158,6 +158,7 @@ Mike Bland
Martin Bless
Pablo Bleyer
Erik van Blokland
Stéphane Blondon
Eric Blossom
Sergey Bobrov
Finn Bock

View file

@ -0,0 +1 @@
Fix display of ``<module>`` call in the html produced by ``cgitb.html()``. Patch by Stéphane Blondon.