Docstrings for classes get "doubled"

Bug #215052 reported by Hans Terlouw
2
Affects Status Importance Assigned to Milestone
Cython
Fix Committed
Medium
Unassigned

Bug Description

Docstrings for classes get "doubled". For example, the docstring in the following Cython code:

class dummy(object):
   "Dummy class documentation"
   pass

will appear "doubled" in the generated C code:

static char __pyx_k_2[] = "Dummy class documentation\nDummy class documentation";

(Docstrings for functions and methods are not affected.)

Revision history for this message
scoder (scoder) wrote :

The code in Nodes.py goes like this:

  class PyClassDefNode(StatNode, BlockNode):
    def __init__(self, pos, name, bases, doc, body):
        # ...
        self.doc = doc
        # ...
        if self.doc and Options.docstrings:
            if Options.embed_pos_in_docstring:
                doc = 'File: %s (starting at line %s)'%relative_position(self.pos)
            doc = doc + '\\n' + self.doc
            doc_node = ExprNodes.StringNode(pos, value = doc)
        else:
            doc_node = None

I have no idea what the

    doc = doc + '\\n' + self.doc

bit is supposed to mean. It looks like it's there for a purpose...

Revision history for this message
scoder (scoder) wrote :

Ah, maybe it just lacks indentation? This makes more sense to me:

        if self.doc and Options.docstrings:
            if Options.embed_pos_in_docstring:
                doc = 'File: %s (starting at line %s)'%relative_position(self.pos)
                doc = doc + '\\n' + self.doc

Revision history for this message
scoder (scoder) wrote :
scoder (scoder)
Changed in cython:
importance: Undecided → Medium
status: New → Fix Committed
Revision history for this message
Hans Terlouw (j-p-terlouw) wrote :

Thanks a lot!

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.