Skip to content

Commit c4f6007

Browse files
miss-islingtonosamakaderStanFromIreland
authored
[3.15] gh-131498: Remove commented-out dead code in cases_generator/analyzer.py (GH-141168) (GH-160461)
Remove the unused analyze_deferred_refs() function that was completely commented out. This function is not referenced anywhere in the codebase and removing it improves code cleanliness. (cherry picked from commit 1c75034) Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com> Co-authored-by: Osama Abdelkader <osama.abdelkader@gmail.com> Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
1 parent bc0ada0 commit c4f6007

1 file changed

Lines changed: 0 additions & 58 deletions

File tree

‎Tools/cases_generator/analyzer.py‎

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -470,64 +470,6 @@ def error(tkn: lexer.Token) -> None:
470470
return res
471471

472472

473-
#def analyze_deferred_refs(node: parser.InstDef) -> dict[lexer.Token, str | None]:
474-
#"""Look for PyStackRef_FromPyObjectNew() calls"""
475-
476-
#def in_frame_push(idx: int) -> bool:
477-
#for tkn in reversed(node.block.tokens[: idx - 1]):
478-
#if tkn.kind in {"SEMI", "LBRACE", "RBRACE"}:
479-
#return False
480-
#if tkn.kind == "IDENTIFIER" and tkn.text == "_PyFrame_PushUnchecked":
481-
#return True
482-
#return False
483-
484-
#refs: dict[lexer.Token, str | None] = {}
485-
#for idx, tkn in enumerate(node.block.tokens):
486-
#if tkn.kind != "IDENTIFIER" or tkn.text != "PyStackRef_FromPyObjectNew":
487-
#continue
488-
489-
#if idx == 0 or node.block.tokens[idx - 1].kind != "EQUALS":
490-
#if in_frame_push(idx):
491-
## PyStackRef_FromPyObjectNew() is called in _PyFrame_PushUnchecked()
492-
#refs[tkn] = None
493-
#continue
494-
#raise analysis_error("Expected '=' before PyStackRef_FromPyObjectNew", tkn)
495-
496-
#lhs = find_assignment_target(node, idx - 1)
497-
#if len(lhs) == 0:
498-
#raise analysis_error(
499-
#"PyStackRef_FromPyObjectNew() must be assigned to an output", tkn
500-
#)
501-
502-
#if lhs[0].kind == "TIMES" or any(
503-
#t.kind == "ARROW" or t.kind == "LBRACKET" for t in lhs[1:]
504-
#):
505-
## Don't handle: *ptr = ..., ptr->field = ..., or ptr[field] = ...
506-
## Assume that they are visible to the GC.
507-
#refs[tkn] = None
508-
#continue
509-
510-
#if len(lhs) != 1 or lhs[0].kind != "IDENTIFIER":
511-
#raise analysis_error(
512-
#"PyStackRef_FromPyObjectNew() must be assigned to an output", tkn
513-
#)
514-
515-
#name = lhs[0].text
516-
#match = (
517-
#any(var.name == name for var in node.inputs)
518-
#or any(var.name == name for var in node.outputs)
519-
#)
520-
#if not match:
521-
#raise analysis_error(
522-
#f"PyStackRef_FromPyObjectNew() must be assigned to an input or output, not '{name}'",
523-
#tkn,
524-
#)
525-
526-
#refs[tkn] = name
527-
528-
#return refs
529-
530-
531473
def variable_used(node: parser.CodeDef, name: str) -> bool:
532474
"""Determine whether a variable with a given name is used in a node."""
533475
return any(

0 commit comments

Comments
 (0)