diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2022-06-10 15:56:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-10 15:56:45 (GMT) |
commit | 53a8b17895e91d08f76a2fb59a555d012cd85ab4 (patch) | |
tree | 4e448db2e89b367fc012d1b5eff0c865f0954b16 /Grammar | |
parent | 21a9a85ff4d62e8fc5a51b8eb56154f32c319b77 (diff) | |
download | cpython-53a8b17895e91d08f76a2fb59a555d012cd85ab4.zip cpython-53a8b17895e91d08f76a2fb59a555d012cd85ab4.tar.gz cpython-53a8b17895e91d08f76a2fb59a555d012cd85ab4.tar.bz2 |
gh-93671: Avoid exponential backtracking in deeply nested sequence patterns in match statements (GH-93680)
Co-authored-by: Ćukasz Langa <lukasz@langa.pl>
Diffstat (limited to 'Grammar')
-rw-r--r-- | Grammar/python.gram | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram index 15c40b6..67b7a55 100644 --- a/Grammar/python.gram +++ b/Grammar/python.gram @@ -471,7 +471,7 @@ or_pattern[pattern_ty]: | patterns[asdl_pattern_seq*]='|'.closed_pattern+ { asdl_seq_LEN(patterns) == 1 ? asdl_seq_GET(patterns, 0) : _PyAST_MatchOr(patterns, EXTRA) } -closed_pattern[pattern_ty]: +closed_pattern[pattern_ty] (memo): | literal_pattern | capture_pattern | wildcard_pattern @@ -558,7 +558,7 @@ maybe_star_pattern[pattern_ty]: | star_pattern | pattern -star_pattern[pattern_ty]: +star_pattern[pattern_ty] (memo): | '*' target=pattern_capture_target { _PyAST_MatchStar(target->v.Name.id, EXTRA) } | '*' wildcard_pattern { @@ -1312,4 +1312,4 @@ invalid_kvpair: | a=expression !(':') { RAISE_ERROR_KNOWN_LOCATION(p, PyExc_SyntaxError, a->lineno, a->end_col_offset - 1, a->end_lineno, -1, "':' expected after dictionary key") } | expression ':' a='*' bitwise_or { RAISE_SYNTAX_ERROR_STARTING_FROM(a, "cannot use a starred expression in a dictionary value") } - | expression a=':' {RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "expression expected after dictionary key and ':'") }
\ No newline at end of file + | expression a=':' {RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "expression expected after dictionary key and ':'") } |