diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-07-05 14:30:41 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-07-05 14:30:41 +0200 |
commit | b6aff5da4a696e2e74e65a43475073679e5e3742 (patch) | |
tree | bf40fa33350579221435c350ed9fbcff8d260be9 /Lib/pydoc.py | |
parent | 9c760eada8f2999455eae55c459a99dbbf11ae81 (diff) | |
download | cpython-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-x | Lib/pydoc.py | 2 |
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( |