mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-44143: Fix crash in the parser when raising tokenizer errors with an exception set (GH-26144) (GH-26148)
(cherry picked from commit 80b089179f
)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
This commit is contained in:
parent
a38db84122
commit
1afaaf5a2d
3 changed files with 4 additions and 0 deletions
|
@ -242,6 +242,7 @@ class ExceptionTests(unittest.TestCase):
|
||||||
""", 9, 24)
|
""", 9, 24)
|
||||||
check("pass\npass\npass\n(1+)\npass\npass\npass", 4, 4)
|
check("pass\npass\npass\n(1+)\npass\npass\npass", 4, 4)
|
||||||
check("(1+)", 1, 4)
|
check("(1+)", 1, 4)
|
||||||
|
check("[interesting\nfoo()\n", 1, 1)
|
||||||
|
|
||||||
# Errors thrown by symtable.c
|
# Errors thrown by symtable.c
|
||||||
check('x = [(yield i) for i in range(3)]', 1, 5)
|
check('x = [(yield i) for i in range(3)]', 1, 5)
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
Fixed a crash in the parser that manifest when raising tokenizer errors when
|
||||||
|
an existing exception was present. Patch by Pablo Galindo.
|
|
@ -1259,6 +1259,7 @@ _PyPegen_check_tokenizer_errors(Parser *p) {
|
||||||
if (p->tok->level != 0) {
|
if (p->tok->level != 0) {
|
||||||
int error_lineno = p->tok->parenlinenostack[p->tok->level-1];
|
int error_lineno = p->tok->parenlinenostack[p->tok->level-1];
|
||||||
if (current_err_line > error_lineno) {
|
if (current_err_line > error_lineno) {
|
||||||
|
PyErr_Clear();
|
||||||
raise_unclosed_parentheses_error(p);
|
raise_unclosed_parentheses_error(p);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue