Repository navigation
Commit 06b2a40
committed
Make pegen output error detection checks after loop body for '*' rules.
Currently, the pegen output produces this for '+' rules:
if (_n == 0 || p->error_indicator) {
PyMem_Free(_children);
p->level--;
return NULL;
}
But for '*' rules, no check is done at all, (skipping the _n == 0 makes sesnse of course)
For '*' it's possible for an error to be raised when parsing children, and currently the parser
sets the error flag/exception but does not return NULL, so parent rules might not detect the
error appropriately, as in this code:
if (
(a = _PyPegen_expect_token(p, FSTRING_START)) // token='FSTRING_START'
&&
(b = _loop0_79_rule(p)) // fstring_middle*
&&
(c = _PyPegen_expect_token(p, FSTRING_END)) // token='FSTRING_END'
)
In this example, _PyPegen_expect_token can raise a SyntaxWarning which trips a debug assert.
This change outputs the same p->error_indicator check for '*' rules as for '+' rules.1 parent 1d19650 commit 06b2a40
4 files changed
Lines changed: 241 additions & 4 deletions
File tree
- Lib/test
- Misc/NEWS.d/next/Core_and_Builtins
- Parser
- Tools/peg_generator/pegen
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
604 | 604 | | |
605 | 605 | | |
606 | 606 | | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
607 | 620 | | |
608 | 621 | | |
609 | 622 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
0 commit comments