[Python-checkins] cpython (merge 3.2 -> default): (merge 3.2) Issue #12451: pydoc: html_getfile() now uses tokenize.open() to

victor.stinner python-checkins at python.org
Tue Jul 5 14:31:55 CEST 2011


http://hg.python.org/cpython/rev/2fbfb7ea362f
changeset:   71232:2fbfb7ea362f
parent:      71229:42e23db3ddfc
parent:      71231:8b62f5d722f4
user:        Victor Stinner <victor.stinner at haypocalc.com>
date:        Tue Jul 05 14:31:28 2011 +0200
summary:
  (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).

files:
  Lib/pydoc.py |  2 +-
  Misc/NEWS    |  4 ++++
  2 files changed, 5 insertions(+), 1 deletions(-)


diff --git a/Lib/pydoc.py b/Lib/pydoc.py
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -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 = '<pre>%s</pre>' % lines
         heading = html.heading(
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -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.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list