mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
gh-104169: Ensure the tokenizer doesn't overwrite previous errors (#104170)
This commit is contained in:
parent
e2ef5015d1
commit
eba64d2afb
1 changed files with 6 additions and 0 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue