From 07ad02f62cc336772e12e3fd837579952b03ca57 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Mon, 30 Apr 2018 11:34:47 +0300 Subject: [PATCH] [2.7] bpo-33256: Replace angle brackets around python object repr to display it in html (GH-6442). (GH-6650) (cherry picked from commit 7d68bfa82654ba01d860b8a772ff63bf0bd183ee) Co-authored-by: sblondon --- Lib/cgitb.py | 4 ++-- Misc/ACKS | 1 + .../next/Library/2018-04-10-20-57-14.bpo-33256.ndHkqu.rst | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2018-04-10-20-57-14.bpo-33256.ndHkqu.rst diff --git a/Lib/cgitb.py b/Lib/cgitb.py index 8acc4b75fe3b..3689f8a4ba02 100644 --- a/Lib/cgitb.py +++ b/Lib/cgitb.py @@ -125,7 +125,7 @@ function calls leading up to the error, in the order they occurred.

''' 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)) @@ -285,7 +285,7 @@ class Hook: if self.display: if plain: - doc = doc.replace('&', '&').replace('<', '<') + doc = pydoc.html.escape(doc) self.file.write('
' + doc + '
\n') else: self.file.write(doc + '\n') diff --git a/Misc/ACKS b/Misc/ACKS index 28255740c7f0..580b0c5bf76d 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -138,6 +138,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 000000000000..a0605c04b4de --- /dev/null +++ b/Misc/NEWS.d/next/Library/2018-04-10-20-57-14.bpo-33256.ndHkqu.rst @@ -0,0 +1 @@ +Fix display of ```` call in the html produced by ``cgitb.html()``. Patch by Stéphane Blondon. -- 2.47.3