8000 gh-98831: Modernize FORMAT_VALUE by gvanrossum · Pull Request #101628 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-98831: Modernize FORMAT_VALUE #101628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 8, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Skip balanced ()/[] blocks in expressions
  • Loading branch information
gvanrossum committed Feb 7, 2023
commit ff87ca4ebc034f9d25c6c881f16bbb349b04ff34
9 changes: 8 additions & 1 deletion Tools/cases_generator/parser.py
Original file line numb 6BE7 er Diff line number Diff line change
Expand Up @@ -263,7 +263,14 @@ def stack_effect(self) -> StackEffect | None:
@contextual
def expression(self) -> Expression | None:
tokens: list[lx.Token] = []
while (tkn := self.peek()) and tkn.kind not in (lx.RBRACKET, lx.RPAREN):
level = 1
while tkn := self.peek():
if tkn.kind in (lx.LBRACKET, lx.LPAREN):
level += 1
elif tkn.kind in (lx.RBRACKET, lx.RPAREN):
level -= 1
if level == 0:
break
tokens.append(tkn)
self.next()
if not tokens:
Expand Down
0