[issue32911] Doc strings no longer stored in body of AST

INADA Naoki report at bugs.python.org
Tue Feb 27 04:38:04 EST 2018


INADA Naoki <songofacandy at gmail.com> added the comment:

I tried this patch:

diff --git a/Python/ast.c b/Python/ast.c
index e2092f0f85..93be2bc839 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -3537,9 +3537,9 @@ docstring_from_stmts(asdl_seq *stmts)
         if (s->kind == Expr_kind && s->v.Expr.value->kind == Str_kind) {
             string doc = s->v.Expr.value->v.Str.s;
             /* not very efficient, but simple */
-            memmove(&asdl_seq_GET(stmts, 0), &asdl_seq_GET(stmts, 1),
-                    (stmts->size - 1) * sizeof(void*));
-            stmts->size--;
+            //memmove(&asdl_seq_GET(stmts, 0), &asdl_seq_GET(stmts, 1),
+            //        (stmts->size - 1) * sizeof(void*));
+            //stmts->size--;
             return doc;
         }
     }

But I got "SyntaxError: from __future__ imports must occur at the beginning of the file".

docstring is very special while it looks like just a single string literal statement...

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32911>
_______________________________________


More information about the Python-bugs-list mailing list