Skip to content

Commit

Permalink
fix: Ignore errors parsing c-extension modules
Browse files Browse the repository at this point in the history
  • Loading branch information
Wang Yuzhi authored and bigeagle committed Dec 9, 2020
1 parent fc15a45 commit 1930054
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/pytkdocs/loader.py
Expand Up @@ -380,7 +380,7 @@ def get_module_documentation(self, node: ObjectNode, select_members=None) -> Mod
except OSError as error:
try:
code = Path(node.file_path).read_text()
except OSError:
except (OSError, UnicodeDecodeError):
self.errors.append(f"Couldn't read source for '{path}': {error}")
source = None
else:
Expand Down Expand Up @@ -441,8 +441,11 @@ def get_class_documentation(self, node: ObjectNode, select_members=None) -> Clas
merge(attributes_data, get_class_attributes(parent_class))
context: Dict[str, Any] = {"attributes": attributes_data}
if "__init__" in class_.__dict__:
attributes_data.update(get_instance_attributes(class_.__init__))
context["signature"] = inspect.signature(class_.__init__)
try:
attributes_data.update(get_instance_attributes(class_.__init__))
context["signature"] = inspect.signature(class_.__init__)
except (TypeError, ValueError):
pass
root_object.parse_docstring(self.docstring_parser, attributes=attributes_data)

if select_members is False:
Expand Down

0 comments on commit 1930054

Please sign in to comment.