(merge 3.2) Issue #12451: pydoc.synopsis() now reads the encoding cookie if

available, to read the Python script from the right encoding.
This commit is contained in:
Victor Stinner 2011-06-30 15:58:29 +02:00
commit 319672e8a6
3 changed files with 20 additions and 5 deletions

View file

@ -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