From 91e08772a6da22166a2ad4ee52fecaf80df9e5e9 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 5 Jul 2011 14:30:41 +0200 Subject: 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). --- Lib/pydoc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Lib/pydoc.py') 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 = '
%s
' % lines heading = html.heading( -- cgit v1.2.1