From e83c3804f49a2ee61fcf2078ad2ddc0521cb0a67 Mon Sep 17 00:00:00 2001 From: Bryan Van de Ven Date: Thu, 11 May 2017 08:40:17 -0500 Subject: [PATCH 1/3] Protect isenumclass predicate against non-class arguments fixes: #3731 Not being a class is another way a thing might not be an enum class, but without an explicit check, isenumclass raises an exception in this case. --- sphinx/util/inspect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py index 861c6f1a2..210ded9f2 100644 --- a/sphinx/util/inspect.py +++ b/sphinx/util/inspect.py @@ -104,7 +104,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): From 90e1aba797e66d631463b5e2dbb44b863605b353 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Fri, 12 May 2017 00:46:29 +0900 Subject: [PATCH 2/3] Update CHANGES for PR #3732 --- CHANGES | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES b/CHANGES index bdecba879..ce0c97af8 100644 --- a/CHANGES +++ b/CHANGES @@ -23,6 +23,7 @@ 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 Testing -------- From 4104b93c6eeccd622652d20a187b77acf7accc7e Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 13 May 2017 15:03:11 +0900 Subject: [PATCH 3/3] Fix #3320: Warning about reference target not being found for container types --- CHANGES | 1 + sphinx/domains/python.py | 2 +- tests/roots/test-domain-py/module.rst | 7 +++++++ tests/test_domain_py.py | 6 +++++- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index ce0c97af8..5c5f55586 100644 --- a/CHANGES +++ b/CHANGES @@ -24,6 +24,7 @@ Bugs fixed * #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 11fa719dc..29656d548 100644 --- a/sphinx/domains/python.py +++ b/sphinx/domains/python.py @@ -110,7 +110,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/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 73766e718..6927e9dc2 100644 --- a/tests/test_domain_py.py +++ b/tests/test_domain_py.py @@ -107,7 +107,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')