Skip to content

Commit

Permalink
gh-104169: Ensure the tokenizer doesn't overwrite previous errors (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
pablogsal authored May 4, 2023
1 parent e2ef501 commit eba64d2
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Parser/tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit eba64d2

Please sign in to comment.