mirror of
https://github.com/python/cpython.git
synced 2025-09-22 00:12:56 +00:00
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:
parent
ad4afeb021
commit
9196dc66ae
2 changed files with 31 additions and 5 deletions
19
Lib/pydoc.py
19
Lib/pydoc.py
|
@ -1870,16 +1870,25 @@ class ModuleScanner:
|
||||||
else:
|
else:
|
||||||
loader = importer.find_module(modname)
|
loader = importer.find_module(modname)
|
||||||
if hasattr(loader,'get_source'):
|
if hasattr(loader,'get_source'):
|
||||||
|
try:
|
||||||
|
source = loader.get_source(modname)
|
||||||
|
except UnicodeDecodeError:
|
||||||
|
if onerror:
|
||||||
|
onerror(modname)
|
||||||
|
continue
|
||||||
import io
|
import io
|
||||||
desc = source_synopsis(
|
desc = source_synopsis(io.StringIO(source)) or ''
|
||||||
io.StringIO(loader.get_source(modname))
|
|
||||||
) or ''
|
|
||||||
if hasattr(loader,'get_filename'):
|
if hasattr(loader,'get_filename'):
|
||||||
path = loader.get_filename(modname)
|
path = loader.get_filename(modname)
|
||||||
else:
|
else:
|
||||||
path = None
|
path = None
|
||||||
else:
|
else:
|
||||||
|
try:
|
||||||
module = loader.load_module(modname)
|
module = loader.load_module(modname)
|
||||||
|
except ImportError:
|
||||||
|
if onerror:
|
||||||
|
onerror(modname)
|
||||||
|
continue
|
||||||
desc = (module.__doc__ or '').splitlines()[0]
|
desc = (module.__doc__ or '').splitlines()[0]
|
||||||
path = getattr(module,'__file__',None)
|
path = getattr(module,'__file__',None)
|
||||||
name = modname + ' - ' + desc
|
name = modname + ' - ' + desc
|
||||||
|
@ -1895,10 +1904,12 @@ 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)
|
||||||
|
def onerror(modname):
|
||||||
|
pass
|
||||||
try: import warnings
|
try: import warnings
|
||||||
except ImportError: pass
|
except ImportError: pass
|
||||||
else: warnings.filterwarnings('ignore') # ignore problems during import
|
else: warnings.filterwarnings('ignore') # ignore problems during import
|
||||||
ModuleScanner().run(callback, key)
|
ModuleScanner().run(callback, key, onerror=onerror)
|
||||||
|
|
||||||
# --------------------------------------------------- web browser interface
|
# --------------------------------------------------- web browser interface
|
||||||
|
|
||||||
|
|
15
Misc/NEWS
15
Misc/NEWS
|
@ -4,6 +4,21 @@ Python News
|
||||||
|
|
||||||
(editors: check NEWS.help for information about editing NEWS using ReST.)
|
(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?
|
What's new in Python 3.0b1?
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue