diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-08-17 10:32:58 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-08-17 10:32:58 +0900 |
commit | a450eb7a7a48fd706c6cdbe6c35be63fd7ff13e6 (patch) | |
tree | f7340d3901bbd2b2c05ced8997b2e70ac440ca5f | |
parent | 2604920232c9c7588f2a6f1ebfa15c506661cb10 (diff) | |
download | sphinx-git-a450eb7a7a48fd706c6cdbe6c35be63fd7ff13e6.tar.gz |
Fix #5306: autodoc: ``getargspec()`` raises NameError for invalid typehints
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | sphinx/ext/autodoc/inspector.py | 7 |
2 files changed, 6 insertions, 2 deletions
@@ -30,6 +30,7 @@ Bugs fixed * autodoc: Optional types are wrongly rendered * #5291: autodoc crashed by ForwardRef types * #5211: autodoc: No docs generated for functools.partial functions +* #5306: autodoc: ``getargspec()`` raises NameError for invalid typehints * #5298: imgmath: math_number_all causes equations to have two numbers in html Testing diff --git a/sphinx/ext/autodoc/inspector.py b/sphinx/ext/autodoc/inspector.py index 6e07c9547..be42237c6 100644 --- a/sphinx/ext/autodoc/inspector.py +++ b/sphinx/ext/autodoc/inspector.py @@ -130,8 +130,11 @@ def formatargspec(function, args, varargs=None, varkw=None, defaults=None, else: return value - introspected_hints = (typing.get_type_hints(function) # type: ignore - if typing and hasattr(function, '__code__') else {}) + try: + introspected_hints = (typing.get_type_hints(function) # type: ignore + if typing and hasattr(function, '__code__') else {}) + except Exception: + introspected_hints = {} fd = StringIO() fd.write('(') |