diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2011-06-30 13:55:43 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2011-06-30 13:55:43 (GMT) |
commit | e6c910e9537d405a11377a478556731b4eaec419 (patch) | |
tree | 2c8e4faafe9da3f52de933940ff0f1e085ea6274 /Lib/pydoc.py | |
parent | dc9b1ea02eba907ae48cea682a49c5df34d0e19e (diff) | |
download | cpython-e6c910e9537d405a11377a478556731b4eaec419.zip cpython-e6c910e9537d405a11377a478556731b4eaec419.tar.gz cpython-e6c910e9537d405a11377a478556731b4eaec419.tar.bz2 |
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 2391013e..1619446 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -57,16 +57,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 @@ -227,7 +228,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 |