Skip to content

Commit 1c7ff67

Browse files
committed
gh-153568: Fix generator typing and the news path
1 parent 717ce38 commit 1c7ff67

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

Misc/NEWS.d/next/Core and Builtins/2026-09-13-10-44-21.gh-issue-153568.operatorloops.rst renamed to Misc/NEWS.d/next/Core_and_Builtins/2026-09-13-10-44-21.gh-issue-153568.operatorloops.rst

File renamed without changes.

Tools/peg_generator/pegen/c_generator.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,9 @@ def initial_calls(node: Any) -> set[str]:
814814
# The seed algorithm retries the base after its last unsuccessful grow.
815815
# Require that retry to reuse a result, not run an operand action again.
816816
for name, rhs in candidates.items():
817-
operand = rhs.alts[-1].items[0].item.value
817+
operand_item = rhs.alts[-1].items[0].item
818+
assert isinstance(operand_item, NameLeaf)
819+
operand = operand_item.value
818820
rule = self.all_rules[operand]
819821
if operand not in candidates and not self._should_memoize(rule):
820822
reject(name, f"requires operand {operand!r} to use (operator_loop), "
@@ -836,7 +838,9 @@ def _handle_operator_loop(self, node: Rule, rhs: Rhs) -> None:
836838
self.print("}")
837839
self.print("int _mark = p->mark;")
838840
self._set_up_token_start_metadata_extraction()
839-
operand = rhs.alts[-1].items[0].item.value
841+
operand_item = rhs.alts[-1].items[0].item
842+
assert isinstance(operand_item, NameLeaf)
843+
operand = operand_item.value
840844
self.print(f"_res = {operand}_rule(p);")
841845
self._check_for_errors()
842846
self.print("if (_res == NULL) {")
@@ -856,6 +860,7 @@ def _handle_operator_loop(self, node: Rule, rhs: Rhs) -> None:
856860
with self.indent():
857861
for alt in rhs.alts[:-1]:
858862
left, operator, right = alt.items
863+
assert isinstance(operator.item, StringLeaf)
859864
token = self.exact_tokens[ast.literal_eval(operator.item.value)]
860865
self.print(f"case {token}: {{")
861866
with self.indent():

0 commit comments

Comments
 (0)