From 7bdc7df3f2da0dafb179dc55740a39d5d9f21062 2024-05-16 12:52:00 From: M Bussonnier Date: 2024-05-16 12:52:00 Subject: [PATCH] Fix crash on completion for optional six modules --- diff --git a/IPython/core/completerlib.py b/IPython/core/completerlib.py index 9b97d70..5ce97ab 100644 --- a/IPython/core/completerlib.py +++ b/IPython/core/completerlib.py @@ -152,9 +152,14 @@ def get_root_modules(): return rootmodules -def is_importable(module, attr, only_modules): +def is_importable(module, attr: str, only_modules) -> bool: if only_modules: - return inspect.ismodule(getattr(module, attr)) + try: + mod = getattr(module, attr) + except ModuleNotFoundError: + # See gh-14434 + return False + return inspect.ismodule(mod) else: return not(attr[:2] == '__' and attr[-2:] == '__')