-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bpo-33256: Replace square brackets around python object repr to display it in html #6442
bpo-33256: Replace square brackets around python object repr to display it in html #6442
Conversation
Lib/cgitb.py
Outdated
@@ -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(func.replace("<", "<").replace(">", ">")) + \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could call pydoc.html.escape like the rest of the code. Maybe it doesn’t matter too much here, but in general it is important to escape ampersands.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vadmium Thank you for the review. :) It's fixed now.
@@ -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)) + \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use pydoc.html.escape()
also in line 285.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 285 is not modified by the patch but I agree it's good to reuse pydoc.html.escape()
there.
I committed the requested change.
@@ -0,0 +1 @@ | |||
Fix display of ``<module>`` call in the html produced by ``cgitb.html()``. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add "Patch by your name." And add your name in Misc/ACKS if it was not added before.
Thanks @sblondon for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 2.7, 3.6, 3.7. |
GH-6637 is a backport of this pull request to the 3.7 branch. |
…y it in html (pythonGH-6442) (cherry picked from commit 7d68bfa) Co-authored-by: sblondon <sblondon@users.noreply.github.com>
Sorry, @sblondon and @serhiy-storchaka, I could not cleanly backport this to |
…y it in html (pythonGH-6442) (cherry picked from commit 7d68bfa) Co-authored-by: sblondon <sblondon@users.noreply.github.com>
GH-6638 is a backport of this pull request to the 3.6 branch. |
…display it in html (pythonGH-6442). (cherry picked from commit 7d68bfa) Co-authored-by: sblondon <sblondon@users.noreply.github.com>
GH-6650 is a backport of this pull request to the 2.7 branch. |
This PR replace '<' and '>' in
func
so an representation of an object will be displayed. It will not change the display of functions.https://bugs.python.org/issue33256