changeset: 71232:2fbfb7ea362f parent: 71229:42e23db3ddfc parent: 71231:8b62f5d722f4 user: Victor Stinner date: Tue Jul 05 14:31:28 2011 +0200 files: Lib/pydoc.py Misc/NEWS description: (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). diff -r 42e23db3ddfc -r 2fbfb7ea362f Lib/pydoc.py --- a/Lib/pydoc.py Tue Jul 05 14:04:39 2011 +0200 +++ b/Lib/pydoc.py Tue Jul 05 14:31:28 2011 +0200 @@ -2311,7 +2311,7 @@ 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( diff -r 42e23db3ddfc -r 2fbfb7ea362f Misc/NEWS --- a/Misc/NEWS Tue Jul 05 14:04:39 2011 +0200 +++ b/Misc/NEWS Tue Jul 05 14:31:28 2011 +0200 @@ -219,6 +219,10 @@ Library ------- +- 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). + - Issue #12493: subprocess: Popen.communicate() now also handles EINTR errors if the process has only one pipe.

AltStyle によって変換されたページ (->オリジナル) /