diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2018-05-29 09:04:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-29 09:04:55 (GMT) |
commit | 73cbe7a01a22d02dbe1ec841e8779c775cad3d08 (patch) | |
tree | 0c39a8adb1cebdfc95cc991223c6c278fb13100a /Python/future.c | |
parent | 2179022d94937d7b0600b0dc192ca6fa5f53d830 (diff) | |
download | cpython-73cbe7a01a22d02dbe1ec841e8779c775cad3d08.zip cpython-73cbe7a01a22d02dbe1ec841e8779c775cad3d08.tar.gz cpython-73cbe7a01a22d02dbe1ec841e8779c775cad3d08.tar.bz2 |
bpo-32911: Revert bpo-29463. (GH-7121) (GH-7197)
Remove the docstring attribute of AST types and restore docstring
expression as a first stmt in their body.
Co-authored-by: INADA Naoki <methane@users.noreply.github.com>
Diffstat (limited to 'Python/future.c')
-rw-r--r-- | Python/future.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Python/future.c b/Python/future.c index ade647f..03a97c8 100644 --- a/Python/future.c +++ b/Python/future.c @@ -63,6 +63,7 @@ static int future_parse(PyFutureFeatures *ff, mod_ty mod, PyObject *filename) { int i, done = 0, prev_line = 0; + stmt_ty first; if (!(mod->kind == Module_kind || mod->kind == Interactive_kind)) return 1; @@ -78,7 +79,15 @@ future_parse(PyFutureFeatures *ff, mod_ty mod, PyObject *filename) but is preceded by a regular import. */ - for (i = 0; i < asdl_seq_LEN(mod->v.Module.body); i++) { + i = 0; + first = (stmt_ty)asdl_seq_GET(mod->v.Module.body, i); + if (first->kind == Expr_kind + && (first->v.Expr.value->kind == Str_kind + || (first->v.Expr.value->kind == Constant_kind + && PyUnicode_CheckExact(first->v.Expr.value->v.Constant.value)))) + i++; + + for (; i < asdl_seq_LEN(mod->v.Module.body); i++) { stmt_ty s = (stmt_ty)asdl_seq_GET(mod->v.Module.body, i); if (done && s->lineno > prev_line) |