chiark / gitweb /
documentation/python: avoid blowing up on __name__ not being an attrib.
authorVladimír Vondruš <mosra@centrum.cz>
Wed, 4 Sep 2019 18:37:15 +0000 (20:37 +0200)
committerVladimír Vondruš <mosra@centrum.cz>
Thu, 5 Sep 2019 16:25:42 +0000 (18:25 +0200)
Don't want to test for this, seems too obscure.

documentation/python.py

index 25ae8388729d1fc31dffa33207420d1821621d99..c7c74440000af55d36b000f14eb812a784bb0ae8 100755 (executable)
@@ -487,7 +487,9 @@ def crawl_module(state: State, path: List[str], module) -> List[Tuple[List[str],
             if inspect.ismodule(object) and object.__name__ != '.'.join(subpath):
                 assert object.__name__ not in state.name_mapping
                 state.name_mapping[object.__name__] = '.'.join(subpath)
-            elif hasattr(object, '__module__'):
+            # logging.Logger objects have __module__ but don't have __name__,
+            # check both
+            elif hasattr(object, '__module__') and hasattr(object, '__name__'):
                 subname = object.__module__ + '.' + object.__name__
                 if subname != '.'.join(subpath):
                     assert subname not in state.name_mapping