From aefb3bbaaac82c30183c584159c62725cdc40033 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 8 Apr 2018 19:39:32 +0900 Subject: [PATCH] Fix #4543: testcase for partialmethod is failed with py3.6.5 --- sphinx/util/inspect.py | 5 ++++- tests/test_autodoc.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py index e8427fd84..492db8700 100644 --- a/sphinx/util/inspect.py +++ b/sphinx/util/inspect.py @@ -313,7 +313,10 @@ class Signature(object): try: self.signature = inspect.signature(subject) except IndexError: - if hasattr(subject, '_partialmethod'): # partialmethod with no argument + # Until python 3.6.4, cpython has been crashed on inspection for + # partialmethods not having any arguments. + # https://bugs.python.org/issue33009 + if hasattr(subject, '_partialmethod'): self.signature = None self.partialmethod_with_noargs = True else: diff --git a/tests/test_autodoc.py b/tests/test_autodoc.py index 9398edc34..ed6d050fa 100644 --- a/tests/test_autodoc.py +++ b/tests/test_autodoc.py @@ -952,7 +952,10 @@ def test_partialmethod(): ' Update state of cell to *state*.', ' ', ] - if sys.version_info < (3, 5, 4): + if (sys.version_info < (3, 5, 4) or + (3, 6, 5) <= sys.version_info < (3, 7) or + (3, 7, 0, 'beta', 3) <= sys.version_info): + # TODO: this condition should be updated after 3.7-final release. expected = '\n'.join(expected).replace(' -> None', '').split('\n') assert call_autodoc('class', 'target.partialmethod.Cell') == expected