From 0ed45d0cbfc7579dfc5527c19aa6e4bb696db2e0 Mon Sep 17 00:00:00 2001 From: Pablo Galindo Date: Fri, 13 Dec 2019 14:04:14 +0000 Subject: [3.7] bpo-39031: Include elif keyword when producing lineno/col-offset info for if_stmt (GH-17582) (#17584) When parsing an "elif" node, lineno and col_offset of the node now point to the "elif" keyword and not to its condition, making it consistent with the "if" node. https://bugs.python.org/issue39031 Automerge-Triggered-By: @pablogsal. (cherry picked from commit 025a602af7ee284d8db6955c26016f3f27d35536) Co-authored-by: Lysandros Nikolaou --- Python/ast.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Python') diff --git a/Python/ast.c b/Python/ast.c index 5a60d6994d6..d1b87d888e5 100644 --- a/Python/ast.c +++ b/Python/ast.c @@ -3622,8 +3622,8 @@ ast_for_if_stmt(struct compiling *c, const node *n) asdl_seq_SET(newobj, 0, If(expression, suite_seq, orelse, - LINENO(CHILD(n, off)), - CHILD(n, off)->n_col_offset, c->c_arena)); + LINENO(CHILD(n, off - 1)), + CHILD(n, off - 1)->n_col_offset, c->c_arena)); orelse = newobj; } expression = ast_for_expr(c, CHILD(n, 1)); -- cgit v1.3.1