diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2023-06-07 11:04:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-07 11:04:40 (GMT) |
commit | ffd26545509b706437ca38bd6db6108c1d0e2326 (patch) | |
tree | 60a2785e5239c132e7ae1f1f2e536d1974476a66 /Python | |
parent | 27c68a6d8f20090310450862c2c299bb7ba3c160 (diff) | |
download | cpython-ffd26545509b706437ca38bd6db6108c1d0e2326.zip cpython-ffd26545509b706437ca38bd6db6108c1d0e2326.tar.gz cpython-ffd26545509b706437ca38bd6db6108c1d0e2326.tar.bz2 |
gh-105390: Correctly raise TokenError instead of SyntaxError for tokenize errors (#105399)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/Python-tokenize.c | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/Python/Python-tokenize.c b/Python/Python-tokenize.c index 223de54..4d21793 100644 --- a/Python/Python-tokenize.c +++ b/Python/Python-tokenize.c @@ -84,13 +84,8 @@ _tokenizer_error(struct tok_state *tok) msg = "invalid token"; break; case E_EOF: - if (tok->level > 0) { - PyErr_Format(PyExc_SyntaxError, - "parenthesis '%c' was never closed", - tok->parenstack[tok->level-1]); - } else { - PyErr_SetString(PyExc_SyntaxError, "unexpected EOF while parsing"); - } + PyErr_SetString(PyExc_SyntaxError, "unexpected EOF in multi-line statement"); + PyErr_SyntaxLocationObject(tok->filename, tok->lineno, tok->inp - tok->buf < 0 ? 0 : tok->inp - tok->buf); return -1; case E_DEDENT: msg = "unindent does not match any outer indentation level"; |