diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-04-29 19:10:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-29 19:10:39 (GMT) |
commit | ef91552cfb4b45f75b415dd43fb6a21795c8dbee (patch) | |
tree | 16a1fa1f6888245bdcbd6f6eca47d5e4550f9b03 | |
parent | a26a297b4ba1b8fe6c97c25af71216935960b343 (diff) | |
download | cpython-ef91552cfb4b45f75b415dd43fb6a21795c8dbee.zip cpython-ef91552cfb4b45f75b415dd43fb6a21795c8dbee.tar.gz cpython-ef91552cfb4b45f75b415dd43fb6a21795c8dbee.tar.bz2 |
bpo-33256: Replace angle brackets around python object repr to display it in html (GH-6442)
(cherry picked from commit 7d68bfa82654ba01d860b8a772ff63bf0bd183ee)
Co-authored-by: sblondon <sblondon@users.noreply.github.com>
-rw-r--r-- | Lib/cgitb.py | 4 | ||||
-rw-r--r-- | Lib/test/test_cgitb.py | 1 | ||||
-rw-r--r-- | Misc/ACKS | 1 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Library/2018-04-10-20-57-14.bpo-33256.ndHkqu.rst | 1 |
4 files changed, 5 insertions, 2 deletions
diff --git a/Lib/cgitb.py b/Lib/cgitb.py index b291100..0f5f32c0 100644 --- a/Lib/cgitb.py +++ b/Lib/cgitb.py @@ -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('&', '&').replace('<', '<') + doc = pydoc.html.escape(doc) self.file.write('<pre>' + doc + '</pre>\n') else: self.file.write(doc + '\n') diff --git a/Lib/test/test_cgitb.py b/Lib/test/test_cgitb.py index a87a422..e299ec3 100644 --- a/Lib/test/test_cgitb.py +++ b/Lib/test/test_cgitb.py @@ -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><module></strong>", out) # By default we emit HTML markup. self.assertIn('<p>', out) self.assertIn('</p>', out) @@ -154,6 +154,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 index 0000000..a0605c0 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2018-04-10-20-57-14.bpo-33256.ndHkqu.rst @@ -0,0 +1 @@ +Fix display of ``<module>`` call in the html produced by ``cgitb.html()``. Patch by Stéphane Blondon. |