Skip to content

Commit 80b0891

Browse files
authored
bpo-44143: Fix crash in the parser when raising tokenizer errors with an exception set (pythonGH-26144)
1 parent 086b5c6 commit 80b0891

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

Lib/test/test_exceptions.py

+1
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ def baz():
242242
""", 9, 24)
243243
check("pass\npass\npass\n(1+)\npass\npass\npass", 4, 4)
244244
check("(1+)", 1, 4)
245+
check("[interesting\nfoo()\n", 1, 1)
245246

246247
# Errors thrown by symtable.c
247248
check('x = [(yield i) for i in range(3)]', 1, 5)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fixed a crash in the parser that manifest when raising tokenizer errors when
2+
an existing exception was present. Patch by Pablo Galindo.

Parser/pegen.c

+1
Original file line numberDiff line numberDiff line change
@@ -1259,6 +1259,7 @@ _PyPegen_check_tokenizer_errors(Parser *p) {
12591259
if (p->tok->level != 0) {
12601260
int error_lineno = p->tok->parenlinenostack[p->tok->level-1];
12611261
if (current_err_line > error_lineno) {
1262+
PyErr_Clear();
12621263
raise_unclosed_parentheses_error(p);
12631264
return -1;
12641265
}

0 commit comments

Comments
 (0)