diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2023-05-04 14:15:26 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-04 14:15:26 (GMT) |
commit | eba64d2afb4c429e80d863dc0dd7808bdbef30d3 (patch) | |
tree | b26bcf1bd6a5f6bf71f7fd0ec989a495465b4d16 /Parser | |
parent | e2ef5015d1b6cb56f1a7988583f2fb8c0e6d65fc (diff) | |
download | cpython-eba64d2afb4c429e80d863dc0dd7808bdbef30d3.zip cpython-eba64d2afb4c429e80d863dc0dd7808bdbef30d3.tar.gz cpython-eba64d2afb4c429e80d863dc0dd7808bdbef30d3.tar.bz2 |
gh-104169: Ensure the tokenizer doesn't overwrite previous errors (#104170)
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/tokenizer.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Parser/tokenizer.c b/Parser/tokenizer.c index 7c07d20..52d0d9a 100644 --- a/Parser/tokenizer.c +++ b/Parser/tokenizer.c @@ -1277,6 +1277,12 @@ _syntaxerror_range(struct tok_state *tok, const char *format, int col_offset, int end_col_offset, va_list vargs) { + // In release builds, we don't want to overwrite a previous error, but in debug builds we + // want to fail if we are not doing it so we can fix it. + assert(tok->done != E_ERROR); + if (tok->done == E_ERROR) { + return ERRORTOKEN; + } PyObject *errmsg, *errtext, *args; errmsg = PyUnicode_FromFormatV(format, vargs); if (!errmsg) { |