summaryrefslogtreecommitdiffstats
path: root/Grammar/python.gram
diff options
context:
space:
mode:
authorLysandros Nikolaou <lisandrosnik@gmail.com>2023-04-27 01:33:31 (GMT)
committerGitHub <noreply@github.com>2023-04-27 01:33:31 (GMT)
commit9169a56fad246364fd3224306e72e0d0725c35aa (patch)
tree2a79d19be8d01fdd08ff5b54080ebfee72ae089d /Grammar/python.gram
parent76632b836cf81a95301f4eb1fa43682e8d9ffa67 (diff)
downloadcpython-9169a56fad246364fd3224306e72e0d0725c35aa.zip
cpython-9169a56fad246364fd3224306e72e0d0725c35aa.tar.gz
cpython-9169a56fad246364fd3224306e72e0d0725c35aa.tar.bz2
gh-103656: Transfer f-string buffers to parser to avoid use-after-free (GH-103896)
Co-authored-by: Pablo Galindo <pablogsal@gmail.com>
Diffstat (limited to 'Grammar/python.gram')
-rw-r--r--Grammar/python.gram11
1 files changed, 5 insertions, 6 deletions
diff --git a/Grammar/python.gram b/Grammar/python.gram
index 3a356c6..6361dcd 100644
--- a/Grammar/python.gram
+++ b/Grammar/python.gram
@@ -881,14 +881,13 @@ fstring_middle[expr_ty]:
| fstring_replacement_field
| t=FSTRING_MIDDLE { _PyPegen_constant_from_token(p, t) }
fstring_replacement_field[expr_ty]:
- | '{' a=(yield_expr | star_expressions) debug_expr="="? conversion=[fstring_conversion] format=[fstring_full_format_spec] '}' {
- _PyPegen_formatted_value(p, a, debug_expr, conversion, format, EXTRA)
- }
+ | '{' a=(yield_expr | star_expressions) debug_expr="="? conversion=[fstring_conversion] format=[fstring_full_format_spec] rbrace='}' {
+ _PyPegen_formatted_value(p, a, debug_expr, conversion, format, rbrace, EXTRA) }
| invalid_replacement_field
-fstring_conversion[expr_ty]:
+fstring_conversion[ResultTokenWithMetadata*]:
| conv_token="!" conv=NAME { _PyPegen_check_fstring_conversion(p, conv_token, conv) }
-fstring_full_format_spec[expr_ty]:
- | ':' spec=fstring_format_spec* { spec ? _PyAST_JoinedStr((asdl_expr_seq*)spec, EXTRA) : NULL }
+fstring_full_format_spec[ResultTokenWithMetadata*]:
+ | colon=':' spec=fstring_format_spec* { _PyPegen_setup_full_format_spec(p, colon, (asdl_expr_seq *) spec, EXTRA) }
fstring_format_spec[expr_ty]:
| t=FSTRING_MIDDLE { _PyPegen_constant_from_token(p, t) }
| fstring_replacement_field