[Python-checkins] cpython (2.7): Issue #7425: Prevent pydoc -k failures due to module import errors.
ned.deily
python-checkins at python.org
Thu Oct 6 23:43:08 CEST 2011
http://hg.python.org/cpython/rev/3acf90f71178
changeset: 72770:3acf90f71178
branch: 2.7
user: Ned Deily <nad at acm.org>
date: Thu Oct 06 14:17:44 2011 -0700
summary:
Issue #7425: Prevent pydoc -k failures due to module import errors.
(Backport to 2.7 of existing 3.x fix)
files:
Lib/pydoc.py | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -52,7 +52,7 @@
# the current directory is changed with os.chdir(), an incorrect
# 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 string import expandtabs, find, join, lower, split, strip, rfind, rstrip
from traceback import extract_tb
@@ -1968,10 +1968,11 @@
if modname[-9:] == '.__init__':
modname = modname[:-9] + ' (package)'
print modname, desc and '- ' + desc
- try: import warnings
- except ImportError: pass
- else: warnings.filterwarnings('ignore') # ignore problems during import
- ModuleScanner().run(callback, key)
+ def onerror(modname):
+ pass
+ with warnings.catch_warnings():
+ warnings.filterwarnings('ignore') # ignore problems during import
+ ModuleScanner().run(callback, key, onerror=onerror)
# --------------------------------------------------- web browser interface
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list