File tree Expand file tree Collapse file tree 1 file changed +3
-10
lines changed Expand file tree Collapse file tree 1 file changed +3
-10
lines changed Original file line number Diff line number Diff line change @@ -1177,14 +1177,9 @@ _PyPegen_check_tokenizer_errors(Parser *p) {
1177
1177
return 0 ;
1178
1178
}
1179
1179
1180
-
1181
1180
Token * current_token = p -> known_err_token != NULL ? p -> known_err_token : p -> tokens [p -> fill - 1 ];
1182
1181
Py_ssize_t current_err_line = current_token -> lineno ;
1183
1182
1184
- // Save the tokenizer state to restore them later in case we found nothing
1185
- struct tok_state saved_tok ;
1186
- memcpy (& saved_tok , p -> tok , sizeof (struct tok_state ));
1187
-
1188
1183
for (;;) {
1189
1184
const char * start ;
1190
1185
const char * end ;
@@ -1206,8 +1201,6 @@ _PyPegen_check_tokenizer_errors(Parser *p) {
1206
1201
break ;
1207
1202
}
1208
1203
1209
- // Restore the tokenizer state
1210
- memcpy (p -> tok , & saved_tok , sizeof (struct tok_state ));
1211
1204
return 0 ;
1212
1205
}
1213
1206
@@ -1239,10 +1232,10 @@ _PyPegen_run_parser(Parser *p)
1239
1232
RAISE_INDENTATION_ERROR ("unexpected unindent" );
1240
1233
}
1241
1234
else {
1242
- if (_PyPegen_check_tokenizer_errors (p )) {
1243
- return NULL ;
1244
- }
1245
1235
RAISE_SYNTAX_ERROR ("invalid syntax" );
1236
+ // _PyPegen_check_tokenizer_errors will override the existing
1237
+ // generic SyntaxError we just raised if errors are found.
1238
+ _PyPegen_check_tokenizer_errors (p );
1246
1239
}
1247
1240
}
1248
1241
return NULL ;
You can’t perform that action at this time.
0 commit comments