From 03809505db22e492a99a3ae19eff6b8666bdc124 Mon Sep 17 00:00:00 2001 From: Kernc Date: Thu, 16 Apr 2020 02:05:38 +0200 Subject: [PATCH] BUG: Fix `Module.is_namespace` crash on dynamic/generated modules --- pdoc/__init__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pdoc/__init__.py b/pdoc/__init__.py index e8935bfc..2596cbf6 100644 --- a/pdoc/__init__.py +++ b/pdoc/__init__.py @@ -773,7 +773,10 @@ def is_namespace(self) -> bool: """ `True` if this module is a namespace package. """ - return self.obj.__spec__.origin in (None, 'namespace') # None in Py3.7+ + try: + return self.obj.__spec__.origin in (None, 'namespace') # None in Py3.7+ + except AttributeError: + return False def find_class(self, cls: type) -> Doc: """