summaryrefslogtreecommitdiff
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-07-05 14:30:41 +0200
committerVictor Stinner <victor.stinner@haypocalc.com>2011-07-05 14:30:41 +0200
commitb6aff5da4a696e2e74e65a43475073679e5e3742 (patch)
treebf40fa33350579221435c350ed9fbcff8d260be9 /Lib/pydoc.py
parent9c760eada8f2999455eae55c459a99dbbf11ae81 (diff)
downloadcpython-b6aff5da4a696e2e74e65a43475073679e5e3742.tar.gz
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).
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-xLib/pydoc.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 2533226025..aa4b6d5c4f 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -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(