diff --git a/CHANGES b/CHANGES index fbfcfd2ab..aa67321dc 100644 --- a/CHANGES +++ b/CHANGES @@ -292,6 +292,8 @@ Bugs fixed * #3702: LaTeX writer styles figure legends with a hard-coded ``\small`` * #3708: LaTeX writer allows irc scheme * #3717: Stop enforcing that favicon's must be .ico +* #3731, #3732: Protect isenumclass predicate against non-class arguments +* #3320: Warning about reference target not being found for container types Testing -------- diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py index 28ea1a08a..eb6fe76cb 100644 --- a/sphinx/domains/python.py +++ b/sphinx/domains/python.py @@ -135,7 +135,7 @@ class PyXrefMixin(object): split_contnode = bool(contnode and contnode.astext() == target) results = [] - for sub_target in sub_targets: + for sub_target in filter(None, sub_targets): if split_contnode: contnode = nodes.Text(sub_target) diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py index 2ae31db15..5e0d219ec 100644 --- a/sphinx/util/inspect.py +++ b/sphinx/util/inspect.py @@ -142,7 +142,7 @@ def isenumclass(x): """Check if the object is subclass of enum.""" if enum is None: return False - return issubclass(x, enum.Enum) + return inspect.isclass(x) and issubclass(x, enum.Enum) def isenumattribute(x): diff --git a/tests/roots/test-domain-py/module.rst b/tests/roots/test-domain-py/module.rst index f3f138639..deb54629e 100644 --- a/tests/roots/test-domain-py/module.rst +++ b/tests/roots/test-domain-py/module.rst @@ -29,3 +29,10 @@ module .. py:class:: ModTopLevel * Link to :py:class:`ModNoModule` + +.. py:function:: foo(x, y) + + :param x: param x + :type x: int + :param y: param y + :type y: tuple(str, float) diff --git a/tests/test_domain_py.py b/tests/test_domain_py.py index eb8a7a178..383dd8d33 100644 --- a/tests/test_domain_py.py +++ b/tests/test_domain_py.py @@ -109,7 +109,11 @@ def test_domain_py_xrefs(app, status, warning): 'ModTopLevel', 'class') assert_refnode(refnodes[6], 'module_b.submodule', 'ModTopLevel', 'ModNoModule', 'class') - assert len(refnodes) == 7 + assert_refnode(refnodes[7], False, False, 'int', 'obj') + assert_refnode(refnodes[8], False, False, 'tuple', 'obj') + assert_refnode(refnodes[9], False, False, 'str', 'obj') + assert_refnode(refnodes[10], False, False, 'float', 'obj') + assert len(refnodes) == 11 @pytest.mark.sphinx('dummy', testroot='domain-py')