mirror of
https://github.com/python/cpython.git
synced 2025-08-24 18:55:00 +00:00
Issue #12451: pydoc: html_getfile() now uses tokenize.open() to support Python
scripts using a encoding different than UTF-8 (read the coding cookie of the script).
This commit is contained in:
parent
2cfb6f3aa0
commit
91e08772a6
2 changed files with 5 additions and 1 deletions
|
@ -2580,7 +2580,7 @@ def _url_handler(url, content_type="text/html"):
|
|||
def html_getfile(path):
|
||||
"""Get and display a source file listing safely."""
|
||||
path = path.replace('%20', ' ')
|
||||
with open(path, 'r') as fp:
|
||||
with tokenize.open(path) as fp:
|
||||
lines = html.escape(fp.read())
|
||||
body = '<pre>%s</pre>' % lines
|
||||
heading = html.heading(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue