Fix #7137: viewcode: Avoid to crash when non-python code given

This commit is contained in:
Takeshi KOMIYA 2020-02-18 00:23:23 +09:00
parent 46f7dc53ef
commit 85138ff449
2 changed files with 2 additions and 1 deletions

View File

@ -22,6 +22,7 @@ Bugs fixed
* #7146: autodoc: IndexError is raised on suppressed type_comment found
* #7161: autodoc: typehints extension does not support parallel build
* #7151: crashed when extension assigns a value to ``env.indexentries``
* #7137: viewcode: Avoid to crash when non-python code given
Testing
--------

View File

@ -66,11 +66,11 @@ def doctree_read(app: Sphinx, doctree: Node) -> None:
if code_tags is None:
try:
analyzer = ModuleAnalyzer.for_module(modname)
analyzer.find_tags()
except Exception:
env._viewcode_modules[modname] = False # type: ignore
return
analyzer.find_tags()
code = analyzer.code
tags = analyzer.tags
else: