From 8c91fb78ce0ac364870c3cd1df2149397f46bd8a Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Thu, 5 Aug 2010 12:53:05 +0200 Subject: [PATCH] #484: Fix crash when duplicating a parameter in an info field list. Problem was that the :type: info nodes were inserted twice into the doctree, which led to inconsistencies when reference nodes were resolved. --- CHANGES | 2 ++ sphinx/util/docfields.py | 7 +++++-- tests/root/objects.txt | 2 ++ tests/test_build_html.py | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index bc122e9c9..f9b3b9a49 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ Release 1.0.2 (in development) ============================== +* #484: Fix crash when duplicating a parameter in an info field list. + * #487: Fix setting the default role to one provided by the ``oldcmarkup`` extension. diff --git a/sphinx/util/docfields.py b/sphinx/util/docfields.py index c8e58f48a..6ce6d82bf 100644 --- a/sphinx/util/docfields.py +++ b/sphinx/util/docfields.py @@ -142,9 +142,12 @@ class TypedField(GroupedField): par += self.make_xref(self.rolename, domain, fieldarg, nodes.strong) if fieldarg in types: par += nodes.Text(' (') - fieldtype = types[fieldarg] + # NOTE: using .pop() here to prevent a single type node to be + # inserted twice into the doctree, which leads to + # inconsistencies later when references are resolved + fieldtype = types.pop(fieldarg) if len(fieldtype) == 1 and isinstance(fieldtype[0], nodes.Text): - typename = u''.join(n.astext() for n in types[fieldarg]) + typename = u''.join(n.astext() for n in fieldtype) par += self.make_xref(self.typerolename, domain, typename) else: par += fieldtype diff --git a/tests/root/objects.txt b/tests/root/objects.txt index 334827de2..d6b8bdf64 100644 --- a/tests/root/objects.txt +++ b/tests/root/objects.txt @@ -62,6 +62,8 @@ Testing object descriptions :ivar int hour: like *hour* :ivar minute: like *minute* :vartype minute: int + :param hour: Duplicate param. Should not lead to crashes. + :type hour: Duplicate type. C items diff --git a/tests/test_build_html.py b/tests/test_build_html.py index 4dee513ae..813c962fe 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -38,7 +38,7 @@ http://www.python.org/logo.png reading included file u'wrongenc.inc' seems to be wrong, try giving an \ :encoding: option\\n? %(root)s/includes.txt:4: WARNING: download file not readable: nonexisting.png -%(root)s/objects.txt:84: WARNING: using old C markup; please migrate to \ +%(root)s/objects.txt:86: WARNING: using old C markup; please migrate to \ new-style markup \(e.g. c:function instead of cfunction\), see \ http://sphinx.pocoo.org/domains.html """