Removed the warning about docstrings for private attributes. Fixed erroneous docstrin...
authorNikita Nemkin <nikita@nemkin.ru>
Sun, 21 Apr 2013 08:26:16 +0000 (14:26 +0600)
committerNikita Nemkin <nikita@nemkin.ru>
Sun, 21 Apr 2013 08:26:16 +0000 (14:26 +0600)
Cython/Compiler/Parsing.py
tests/errors/w_attr_docstrings.pyx [deleted file]
tests/run/embedsignatures.pyx

index fb8d908..a75e38a 100644 (file)
@@ -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 (file)
index 252dfea..0000000
+++ /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.
-"""
index 606582f..81997df 100644 (file)
@@ -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