mirror of
https://github.com/python/cpython.git
synced 2025-08-01 07:33:08 +00:00
Issue #7425: Prevent pydoc -k failures due to module import errors.
(Backport to 2.7 of existing 3.x fix)
This commit is contained in:
parent
ac6874c4bb
commit
0096fb5780
1 changed files with 6 additions and 5 deletions
11
Lib/pydoc.py
11
Lib/pydoc.py
|
@ -52,7 +52,7 @@ Richard Chamberlain, for the first implementation of textdoc.
|
||||||
# the current directory is changed with os.chdir(), an incorrect
|
# the current directory is changed with os.chdir(), an incorrect
|
||||||
# path will be displayed.
|
# path will be displayed.
|
||||||
|
|
||||||
import sys, imp, os, re, types, inspect, __builtin__, pkgutil
|
import sys, imp, os, re, types, inspect, __builtin__, pkgutil, warnings
|
||||||
from repr import Repr
|
from repr import Repr
|
||||||
from string import expandtabs, find, join, lower, split, strip, rfind, rstrip
|
from string import expandtabs, find, join, lower, split, strip, rfind, rstrip
|
||||||
from traceback import extract_tb
|
from traceback import extract_tb
|
||||||
|
@ -1968,10 +1968,11 @@ def apropos(key):
|
||||||
if modname[-9:] == '.__init__':
|
if modname[-9:] == '.__init__':
|
||||||
modname = modname[:-9] + ' (package)'
|
modname = modname[:-9] + ' (package)'
|
||||||
print modname, desc and '- ' + desc
|
print modname, desc and '- ' + desc
|
||||||
try: import warnings
|
def onerror(modname):
|
||||||
except ImportError: pass
|
pass
|
||||||
else: warnings.filterwarnings('ignore') # ignore problems during import
|
with warnings.catch_warnings():
|
||||||
ModuleScanner().run(callback, key)
|
warnings.filterwarnings('ignore') # ignore problems during import
|
||||||
|
ModuleScanner().run(callback, key, onerror=onerror)
|
||||||
|
|
||||||
# --------------------------------------------------- web browser interface
|
# --------------------------------------------------- web browser interface
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue