diff options
Diffstat (limited to 'Parser/pegen.c')
-rw-r--r-- | Parser/pegen.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Parser/pegen.c b/Parser/pegen.c index 953480d..d2b7ec4 100644 --- a/Parser/pegen.c +++ b/Parser/pegen.c @@ -328,6 +328,7 @@ tokenizer_error(Parser *p) const char *msg = NULL; PyObject* errtype = PyExc_SyntaxError; + Py_ssize_t col_offset = -1; switch (p->tok->done) { case E_TOKEN: msg = "invalid token"; @@ -359,16 +360,14 @@ tokenizer_error(Parser *p) msg = "too many levels of indentation"; break; case E_LINECONT: + col_offset = strlen(strtok(p->tok->buf, "\n")) - 1; msg = "unexpected character after line continuation character"; break; default: msg = "unknown parsing error"; } - PyErr_Format(errtype, msg); - // There is no reliable column information for this error - PyErr_SyntaxLocationObject(p->tok->filename, p->tok->lineno, 0); - + RAISE_ERROR_KNOWN_LOCATION(p, errtype, p->tok->lineno, col_offset, msg); return -1; } |