From eb9c18b1bc6d7b870d05f92355f9c7b8218254a0 Mon Sep 17 00:00:00 2001 From: Daniel Pizetta Date: Mon, 4 Sep 2017 16:14:30 -0300 Subject: [PATCH] Fix #4019: exception treatment for NoneType group attibute. --- sphinx/ext/inheritance_diagram.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/sphinx/ext/inheritance_diagram.py b/sphinx/ext/inheritance_diagram.py index f5b0228a5ff..f7cf3411104 100644 --- a/sphinx/ext/inheritance_diagram.py +++ b/sphinx/ext/inheritance_diagram.py @@ -80,14 +80,18 @@ def try_import(objname): __import__(objname) return sys.modules.get(objname) # type: ignore except ImportError: - modname, attrname = module_sig_re.match(objname).groups() # type: ignore - if modname is None: - return None try: - __import__(modname) - return getattr(sys.modules.get(modname), attrname, None) - except ImportError: + modname, attrname = module_sig_re.match(objname).groups() # type: ignore + except AttributeError: return None + else: + if modname is None: + return None + try: + __import__(modname) + return getattr(sys.modules.get(modname), attrname, None) + except ImportError: + return None def import_classes(name, currmodule):