diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-06-30 13:58:29 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-06-30 13:58:29 (GMT) |
commit | 319672e8a6ca3239573340dfb3d8fa46f7f53f0c (patch) | |
tree | dfa4fb2be5e97b5f633597861537cb1c5ced2a6e /Lib/pydoc.py | |
parent | 0b5e049ea01f7b0506a8fe596f1d79e2350fc9a4 (diff) | |
parent | e6c910e9537d405a11377a478556731b4eaec419 (diff) | |
download | cpython-319672e8a6ca3239573340dfb3d8fa46f7f53f0c.zip cpython-319672e8a6ca3239573340dfb3d8fa46f7f53f0c.tar.gz cpython-319672e8a6ca3239573340dfb3d8fa46f7f53f0c.tar.bz2 |
(merge 3.2) Issue #12451: pydoc.synopsis() now reads the encoding cookie if
available, to read the Python script from the right encoding.
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-x | Lib/pydoc.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 89d00a3..a39962e 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -51,16 +51,17 @@ Richard Chamberlain, for the first implementation of textdoc. # the current directory is changed with os.chdir(), an incorrect # path will be displayed. -import os -import sys import builtins import imp -import io import inspect +import io +import os import pkgutil import platform import re +import sys import time +import tokenize import warnings from collections import deque from reprlib import Repr @@ -221,7 +222,7 @@ def synopsis(filename, cache={}): if lastupdate < mtime: info = inspect.getmoduleinfo(filename) try: - file = open(filename) + file = tokenize.open(filename) except IOError: # module can't be opened, so skip it return None |