summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-07-05 12:30:41 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-07-05 12:30:41 (GMT)
commit91e08772a6da22166a2ad4ee52fecaf80df9e5e9 (patch)
treea175288f0a1ebe6839f2022cab7750bb31bb6e77 /Lib
parent2cfb6f3aa086b1f500516372f7179f10c123a777 (diff)
downloadcpython-91e08772a6da22166a2ad4ee52fecaf80df9e5e9.zip
cpython-91e08772a6da22166a2ad4ee52fecaf80df9e5e9.tar.gz
cpython-91e08772a6da22166a2ad4ee52fecaf80df9e5e9.tar.bz2
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')
-rwxr-xr-xLib/pydoc.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 2533226..aa4b6d5 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(