Issue 3145: help("modules xxx") failed when scanning test.badsyntax_pep3120...

now it silently ignores modules it cannot scan or import.
This commit is contained in:
Amaury Forgeot d'Arc 2008-06-19 20:54:32 +00:00
parent ad4afeb021
commit 9196dc66ae
2 changed files with 31 additions and 5 deletions

View File

@ -1870,16 +1870,25 @@ class ModuleScanner:
else:
loader = importer.find_module(modname)
if hasattr(loader,'get_source'):
try:
source = loader.get_source(modname)
except UnicodeDecodeError:
if onerror:
onerror(modname)
continue
import io
desc = source_synopsis(
io.StringIO(loader.get_source(modname))
) or ''
desc = source_synopsis(io.StringIO(source)) or ''
if hasattr(loader,'get_filename'):
path = loader.get_filename(modname)
else:
path = None
else:
try:
module = loader.load_module(modname)
except ImportError:
if onerror:
onerror(modname)
continue
desc = (module.__doc__ or '').splitlines()[0]
path = getattr(module,'__file__',None)
name = modname + ' - ' + desc
@ -1895,10 +1904,12 @@ def apropos(key):
if modname[-9:] == '.__init__':
modname = modname[:-9] + ' (package)'
print(modname, desc and '- ' + desc)
def onerror(modname):
pass
try: import warnings
except ImportError: pass
else: warnings.filterwarnings('ignore') # ignore problems during import
ModuleScanner().run(callback, key)
ModuleScanner().run(callback, key, onerror=onerror)
# --------------------------------------------------- web browser interface

View File

@ -4,6 +4,21 @@ Python News
(editors: check NEWS.help for information about editing NEWS using ReST.)
What's new in Python 3.0b2?
===========================
*Release date: XX-XXX-2008*
Core and Builtins
-----------------
Library
-------
- Issue #3145: help("modules whatever") failed when trying to load the source
code of every single module of the standard library, including invalid files
used in the test suite.
What's new in Python 3.0b1?
===========================