From 5f696ed119fc77e5c57649d67984e691e59fc8ed Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Tue, 11 May 2021 23:25:21 +0900 Subject: [PATCH] Fix #9210: viewcode: crashed if non importable modules found on parallel build --- CHANGES | 2 ++ sphinx/ext/viewcode.py | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index 8cb39f267..45a959e39 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,8 @@ Features added Bugs fixed ---------- +* #9210: viewcode: crashed if non importable modules found on parallel build + Testing -------- diff --git a/sphinx/ext/viewcode.py b/sphinx/ext/viewcode.py index f2a42f33f..5728f6077 100644 --- a/sphinx/ext/viewcode.py +++ b/sphinx/ext/viewcode.py @@ -150,10 +150,11 @@ def env_merge_info(app: Sphinx, env: BuildEnvironment, docnames: Iterable[str], if modname not in env._viewcode_modules: # type: ignore env._viewcode_modules[modname] = entry # type: ignore else: - used = env._viewcode_modules[modname][2] # type: ignore - for fullname, docname in entry[2].items(): - if fullname not in used: - used[fullname] = docname + if env._viewcode_modules[modname]: # type: ignore + used = env._viewcode_modules[modname][2] # type: ignore + for fullname, docname in entry[2].items(): + if fullname not in used: + used[fullname] = docname def env_purge_doc(app: Sphinx, env: BuildEnvironment, docname: str) -> None: