summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-07-05 12:31:28 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-07-05 12:31:28 (GMT)
commitd7772bc4cb42418f1fd347afe777fd7a6d5a7287 (patch)
treeb4789ea50700010a00fab494bfc8ff925da9ebb8 /Lib
parent5b1261d750793539cf4508a1e76c2f6d20900ac7 (diff)
parent91e08772a6da22166a2ad4ee52fecaf80df9e5e9 (diff)
downloadcpython-d7772bc4cb42418f1fd347afe777fd7a6d5a7287.zip
cpython-d7772bc4cb42418f1fd347afe777fd7a6d5a7287.tar.gz
cpython-d7772bc4cb42418f1fd347afe777fd7a6d5a7287.tar.bz2
(merge 3.2) 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 ad6d7c7..ffb4f89 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -2311,7 +2311,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(