Skip to content
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

Conversation

sblondon
Copy link
Contributor

@sblondon sblondon commented Apr 10, 2018

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

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("<", "&lt;").replace(">", "&gt;")) + \
Copy link
Member

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.

Copy link
Contributor Author

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)) + \
Copy link
Member

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.

Copy link
Contributor Author

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()``.
Copy link
Member

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.

@serhiy-storchaka serhiy-storchaka merged commit 7d68bfa into python:master Apr 29, 2018
@miss-islington
Copy link
Contributor

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.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-6637 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 29, 2018
…y it in html (pythonGH-6442)

(cherry picked from commit 7d68bfa)

Co-authored-by: sblondon <sblondon@users.noreply.github.com>
@miss-islington
Copy link
Contributor

Sorry, @sblondon and @serhiy-storchaka, I could not cleanly backport this to 2.7 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 7d68bfa82654ba01d860b8a772ff63bf0bd183ee 2.7

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 29, 2018
…y it in html (pythonGH-6442)

(cherry picked from commit 7d68bfa)

Co-authored-by: sblondon <sblondon@users.noreply.github.com>
@bedevere-bot
Copy link

GH-6638 is a backport of this pull request to the 3.6 branch.

miss-islington added a commit that referenced this pull request Apr 29, 2018
…y it in html (GH-6442)

(cherry picked from commit 7d68bfa)

Co-authored-by: sblondon <sblondon@users.noreply.github.com>
miss-islington added a commit that referenced this pull request Apr 29, 2018
…y it in html (GH-6442)

(cherry picked from commit 7d68bfa)

Co-authored-by: sblondon <sblondon@users.noreply.github.com>
serhiy-storchaka pushed a commit to serhiy-storchaka/cpython that referenced this pull request Apr 30, 2018
…display it in html (pythonGH-6442).

(cherry picked from commit 7d68bfa)

Co-authored-by: sblondon <sblondon@users.noreply.github.com>
@bedevere-bot
Copy link

GH-6650 is a backport of this pull request to the 2.7 branch.

serhiy-storchaka added a commit that referenced this pull request Apr 30, 2018
…display it in html (GH-6442). (GH-6650)

(cherry picked from commit 7d68bfa)

Co-authored-by: sblondon <sblondon@users.noreply.github.com>
@sblondon sblondon deleted the remove-angle-brackets-to-display-module branch April 30, 2021 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants