Gracefully handle situation where module name is unknown.

This commit is contained in:
Georg Brandl
2008-04-13 17:43:59 +00:00
parent 2786397971
commit 47ede06270

View File

@@ -100,6 +100,13 @@ def generate_rst(what, name, members, undoc, add_content, document, lineno,
result = ViewList()
if mod is None:
warning = document.reporter.warning(
'don\'t know which module to import for documenting '
'%r (try placing a "module" directive in the document, '
'or giving an explicit module name)' % name, line=lineno)
return [warning], result
try:
todoc = module = __import__(mod, None, None, ['foo'])
if filename_set is not None and hasattr(module, '__file__') and module.__file__: