Skip to content

Commit 9c6543a

Browse files
committed
DOC: fix ImportErrors in apigen.py for Python 3
1 parent e5b4851 commit 9c6543a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

doc/tools/apigen.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,11 @@ def _parse_module_with_import(self, uri):
207207
classes : list of str
208208
A list of (public) class names in the module.
209209
"""
210-
mod = __import__(uri, fromlist=[uri])
210+
try:
211+
mod = __import__(uri, fromlist=[uri])
212+
except ImportError:
213+
# fix ImportError for submodules in Python 3
214+
mod = __import__(uri, fromlist=[])
211215
# find all public objects in the module.
212216
obj_strs = [obj for obj in dir(mod) if not obj.startswith('_')]
213217
functions = []

0 commit comments

Comments
 (0)