8000 gh-104169: Ensure the tokenizer doesn't overwrite previous errors (#1… · python/cpython@eba64d2 · GitHub
[go: up one dir, main page]

Skip to content

Commit eba64d2

Browse files
authored
gh-104169: Ensure the tokenizer doesn't overwrite previous errors (#104170)
1 parent e2ef501 commit eba64d2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Parser/tokenizer.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,12 @@ _syntaxerror_range(struct tok_state *tok, const char *format,
12771277
int col_offset, int end_col_offset,
12781278
va_list vargs)
12791279
{
1280+
// In release builds, we don't want to overwrite a previous error, but in debug builds we
1281+
// want to fail if we are not doing it so we can fix it.
1282+
assert(tok->done != E_ERROR);
1283+
if (tok->done == E_ERROR) {
1284+
return ERRORTOKEN;
1285+
}
12801286
PyObject *errmsg, *errtext, *args;
12811287
errmsg = PyUnicode_FromFormatV(format, vargs);
12821288
if (!errmsg) {

0 commit comments

Comments
 (0)
0