mirror of https://github.com/python/cpython
gh-104169: Ensure the tokenizer doesn't overwrite previous errors (#104170)
This commit is contained in:
parent
e2ef5015d1
commit
eba64d2afb
|
@ -1277,6 +1277,12 @@ _syntaxerror_range(struct tok_state *tok, const char *format,
|
||||||
int col_offset, int end_col_offset,
|
int col_offset, int end_col_offset,
|
||||||
va_list vargs)
|
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;
|
PyObject *errmsg, *errtext, *args;
|
||||||
errmsg = PyUnicode_FromFormatV(format, vargs);
|
errmsg = PyUnicode_FromFormatV(format, vargs);
|
||||||
if (!errmsg) {
|
if (!errmsg) {
|
||||||
|
|
Loading…
Reference in New Issue