From: Nikita Nemkin Date: Sun, 21 Apr 2013 08:26:16 +0000 (+0600) Subject: Removed the warning about docstrings for private attributes. Fixed erroneous docstrin... X-Git-Tag: 0.19.1~31^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=409e24f6a78a677a78861bf5ea039e4470b773eb;p=platform%2Fupstream%2Fpython-cython.git Removed the warning about docstrings for private attributes. Fixed erroneous docstring recognition past the blank line. --- diff --git a/Cython/Compiler/Parsing.py b/Cython/Compiler/Parsing.py index fb8d908..a75e38a 100644 --- a/Cython/Compiler/Parsing.py +++ b/Cython/Compiler/Parsing.py @@ -2807,12 +2807,10 @@ def p_c_func_or_var_declaration(s, pos, ctx): declarator = p_c_declarator(s, ctx, cmethod_flag = cmethod_flag, assignable = 1, nonempty = 1) declarators.append(declarator) + doc_line = s.start_line + 1 s.expect_newline("Syntax error in C variable declaration") - if ctx.level == 'c_class': - doc_pos = s.position() + if ctx.level == 'c_class' and s.start_line == doc_line: doc = p_doc_string(s) - if doc and ctx.visibility not in ('public', 'readonly'): - warning(doc_pos, "Private attributes don't support docstrings.", 1) else: doc = None result = Nodes.CVarDefNode(pos, diff --git a/tests/errors/w_attr_docstrings.pyx b/tests/errors/w_attr_docstrings.pyx deleted file mode 100644 index 252dfea..0000000 --- a/tests/errors/w_attr_docstrings.pyx +++ /dev/null @@ -1,26 +0,0 @@ -# mode: error -# tag: werror - -cdef class A: - cdef a - """docstring""" - - cdef int b - """docstring""" - - cdef public c - """docstring""" - - cdef public dict d - """docstring""" - - cdef readonly e - """docstring""" - - cdef readonly list e - """docstring""" - -_ERRORS = """ -6:4: Private attributes don't support docstrings. -9:4: Private attributes don't support docstrings. -""" diff --git a/tests/run/embedsignatures.pyx b/tests/run/embedsignatures.pyx index 606582f..81997df 100644 --- a/tests/run/embedsignatures.pyx +++ b/tests/run/embedsignatures.pyx @@ -22,6 +22,9 @@ __doc__ = ur""" None >>> print (Ext.attr4.__doc__) attr4 docstring + >>> print (Ext.attr5.__doc__) + attr5: 'int' + attr5 docstring >>> print (Ext.a.__doc__) Ext.a(self) @@ -185,8 +188,13 @@ cdef class Ext: cdef public attr1 """attr1 docstring""" cdef public list attr2 - cdef public Ext attr3 + cdef public Ext attr3 + + """NOT attr3 docstring""" cdef int attr4 + cdef public int \ + attr5 + """attr5 docstring""" CONST1, CONST2 = 1, 2