summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-06-07 11:38:36 (GMT)
committerGitHub <noreply@github.com>2023-06-07 11:38:36 (GMT)
commitc84d4d165dd92e41d6d8661e71b9fd9ac03bfd9e (patch)
treee8f0ccd59d0f309720d7312e594e64703317c560 /Python
parentc607551baf62d7201b147f20095160eee0140684 (diff)
downloadcpython-c84d4d165dd92e41d6d8661e71b9fd9ac03bfd9e.zip
cpython-c84d4d165dd92e41d6d8661e71b9fd9ac03bfd9e.tar.gz
cpython-c84d4d165dd92e41d6d8661e71b9fd9ac03bfd9e.tar.bz2
[3.12] gh-105390: Correctly raise TokenError instead of SyntaxError for tokenize errors (GH-105399) (#105439)
Diffstat (limited to 'Python')
-rw-r--r--Python/Python-tokenize.c9
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";