]> granicus.if.org Git - python/commitdiff
bpo-33256: Replace angle brackets around python object repr to display it in html...
authorsblondon <sblondon@users.noreply.github.com>
Sun, 29 Apr 2018 17:48:33 +0000 (19:48 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 29 Apr 2018 17:48:33 +0000 (20:48 +0300)
Lib/cgitb.py
Lib/test/test_cgitb.py
Misc/ACKS
Misc/NEWS.d/next/Library/2018-04-10-20-57-14.bpo-33256.ndHkqu.rst [new file with mode: 0644]

index b29110018cd104c4d41256c25a704cb6cd705ba3..0f5f32c0fadee1cf828079f81dded6a5695ac627 100644 (file)
@@ -124,7 +124,7 @@ function calls leading up to the error, in the order they occurred.</p>'''
         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 @@ class Hook:
 
         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')
index a87a4224f94ddc4e5b3b54ccfef8fd8c53df41f5..e299ec3ec6ceb59331703412ff62f9f4ceea5a3a 100644 (file)
@@ -45,6 +45,7 @@ class TestCgitb(unittest.TestCase):
         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)
index c96f31c80d177ac0a7e6b87016c1f2e46616386b..3b6774219f6c6c4bacfcf212478d5bceb978ba99 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -158,6 +158,7 @@ Mike Bland
 Martin Bless
 Pablo Bleyer
 Erik van Blokland
+Stéphane Blondon
 Eric Blossom
 Sergey Bobrov
 Finn Bock
diff --git a/Misc/NEWS.d/next/Library/2018-04-10-20-57-14.bpo-33256.ndHkqu.rst b/Misc/NEWS.d/next/Library/2018-04-10-20-57-14.bpo-33256.ndHkqu.rst
new file mode 100644 (file)
index 0000000..a0605c0
--- /dev/null
@@ -0,0 +1 @@
+Fix display of ``<module>`` call in the html produced by ``cgitb.html()``. Patch by Stéphane Blondon.