summaryrefslogtreecommitdiffstats
path: root/Parser
diff options
context:
space:
mode:
authorLysandros Nikolaou <lisandrosnik@gmail.com>2020-04-15 18:22:10 (GMT)
committerGitHub <noreply@github.com>2020-04-15 18:22:10 (GMT)
commit9a4b38f66b3e674db94e07980e1cacb39e388c73 (patch)
treeb8046dd0e0b7b9bf0e3592b88c9dc0cd2c7f7ae5 /Parser
parent574547a75c79b506261520c5773ae08a1dcea1b9 (diff)
downloadcpython-9a4b38f66b3e674db94e07980e1cacb39e388c73.zip
cpython-9a4b38f66b3e674db94e07980e1cacb39e388c73.tar.gz
cpython-9a4b38f66b3e674db94e07980e1cacb39e388c73.tar.bz2
bpo-40267: Fix message when last input character produces a SyntaxError (GH-19521)
When there is a SyntaxError after reading the last input character from the tokenizer and if no newline follows it, the error message used to be `unexpected EOF while parsing`, which is wrong.
Diffstat (limited to 'Parser')
-rw-r--r--Parser/parsetok.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Parser/parsetok.c b/Parser/parsetok.c
index cb94721..37ca65c 100644
--- a/Parser/parsetok.c
+++ b/Parser/parsetok.c
@@ -332,6 +332,9 @@ parsetok(struct tok_state *tok, grammar *g, int start, perrdetail *err_ret,
PyParser_AddToken(ps, (int)type, str,
lineno, col_offset, tok->lineno, end_col_offset,
&(err_ret->expected))) != E_OK) {
+ if (tok->done == E_EOF && !ISWHITESPACE(type)) {
+ tok->done = E_SYNTAX;
+ }
if (err_ret->error != E_DONE) {
PyObject_FREE(str);
err_ret->token = type;