# Description: Handle problems encountered with docutils 0.6. # The problem here is that the child.data element does not always exist any # more. Apparently, the child element is sometimes a string instead. So, we # work around it by only executing the code in question if child.data can be # referenced. Thanks to Thomas Hille for research and the initial patch. # Bug-Debian: http://bugs.debian.org/561793 # Author: Kenneth J. Pronovici --- a/epydoc/markup/restructuredtext.py +++ b/epydoc/markup/restructuredtext.py @@ -304,13 +304,14 @@ class _SummaryExtractor(NodeVisitor): # Extract the first sentence. for child in node: if isinstance(child, docutils.nodes.Text): - m = self._SUMMARY_RE.match(child.data) - if m: - summary_pieces.append(docutils.nodes.Text(m.group(1))) - other = child.data[m.end():] - if other and not other.isspace(): - self.other_docs = True - break + if hasattr(child, 'data'): + m = self._SUMMARY_RE.match(child.data) + if m: + summary_pieces.append(docutils.nodes.Text(m.group(1))) + other = child.data[m.end():] + if other and not other.isspace(): + self.other_docs = True + break summary_pieces.append(child) summary_doc = self.document.copy() # shallow copy @@ -489,10 +490,11 @@ class _SplitFieldsTranslator(NodeVisitor if (len(fbody[0]) > 0 and isinstance(fbody[0][0], docutils.nodes.Text)): child = fbody[0][0] - if child.data[:1] in ':-': - child.data = child.data[1:].lstrip() - elif child.data[:2] in (' -', ' :'): - child.data = child.data[2:].lstrip() + if hasattr(child, 'data'): + if child.data[:1] in ':-': + child.data = child.data[1:].lstrip() + elif child.data[:2] in (' -', ' :'): + child.data = child.data[2:].lstrip() # Wrap the field body, and add a new field self._add_field(tagname, arg, fbody)