summaryrefslogtreecommitdiffstats
path: root/Parser/tokenizer.c
diff options
context:
space:
mode:
authorAnthony Sottile <asottile@umich.edu>2019-01-13 04:05:13 (GMT)
committerINADA Naoki <methane@users.noreply.github.com>2019-01-13 04:05:13 (GMT)
commit995d9b92979768125ced4da3a56f755bcdf80f6e (patch)
tree2184ab1771b87883a92391f41229a12ce4cbd9d3 /Parser/tokenizer.c
parent1cffd0eed313011c0c2bb071c8affeb4a7ed05c7 (diff)
downloadcpython-995d9b92979768125ced4da3a56f755bcdf80f6e.zip
cpython-995d9b92979768125ced4da3a56f755bcdf80f6e.tar.gz
cpython-995d9b92979768125ced4da3a56f755bcdf80f6e.tar.bz2
bpo-16806: Fix `lineno` and `col_offset` for multi-line string tokens (GH-10021)
Diffstat (limited to 'Parser/tokenizer.c')
-rw-r--r--Parser/tokenizer.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c
index 0e6c1a8..3e3cf2c 100644
--- a/Parser/tokenizer.c
+++ b/Parser/tokenizer.c
@@ -1519,6 +1519,13 @@ tok_get(struct tok_state *tok, char **p_start, char **p_end)
int quote_size = 1; /* 1 or 3 */
int end_quote_size = 0;
+ /* Nodes of type STRING, especially multi line strings
+ must be handled differently in order to get both
+ the starting line number and the column offset right.
+ (cf. issue 16806) */
+ tok->first_lineno = tok->lineno;
+ tok->multi_line_start = tok->line_start;
+
/* Find the quote size and start of string */
c = tok_nextc(tok);
if (c == quote) {