Skip to content
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

Remove comments from find_assignment_target result #128742

Open
WolframAlph opened this issue Jan 11, 2025 · 0 comments
Open

Remove comments from find_assignment_target result #128742

WolframAlph opened this issue Jan 11, 2025 · 0 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error

Comments

@WolframAlph
Copy link
Contributor

WolframAlph commented Jan 11, 2025

Bug report

Bug description:

Tools/cases_generator/tier1_generator.py fails if you place comment before PyStackRef_FromPyObjectNew assignment. Example reproducer (bytecodes.c:291-293):

pure inst(LOAD_CONST, (-- value)) {
     // comment
    value = PyStackRef_FromPyObjectNew(GETITEM(FRAME_CO_CONSTS, oparg));
}
/python.exe Tools/cases_generator/tier1_generator.py

Traceback (most recent call last):
  File "/Users/yyanchii/Desktop/cpython/Tools/cases_generator/tier1_generator.py", line 221, in <module>
    data = analyze_files(args.input)
  File "/Users/yyanchii/Desktop/cpython/Tools/cases_generator/analyzer.py", line 1184, in analyze_files
    return analyze_forest(parser.parse_files(filenames))
  File "/Users/yyanchii/Desktop/cpython/Tools/cases_generator/analyzer.py", line 1133, in analyze_forest
    desugar_inst(node, instructions, uops)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/yyanchii/Desktop/cpython/Tools/cases_generator/analyzer.py", line 947, in desugar_inst
    uop = make_uop("_" + inst.name, inst, op_inputs, uops)
  File "/Users/yyanchii/Desktop/cpython/Tools/cases_generator/analyzer.py", line 854, in make_uop
    deferred_refs=analyze_deferred_refs(op),
                  ~~~~~~~~~~~~~~~~~~~~~^^^^
  File "/Users/yyanchii/Desktop/cpython/Tools/cases_generator/analyzer.py", line 458, in analyze_deferred_refs
    raise analysis_error(
        "PyStackRef_FromPyObjectNew() must be assigned to an output", tkn
    )
  File "/Users/yyanchii/Desktop/cpython/Python/bytecodes.c", line 293
    
    ^
SyntaxError: PyStackRef_FromPyObjectNew() must be assigned to an output

Problem is in:

if len(lhs) != 1 or lhs[0].kind != "IDENTIFIER":
raise analysis_error(
"PyStackRef_FromPyObjectNew() must be assigned to an output", tkn
)

as lhs may contain leading comments which are ignored during extraction.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux, macOS, Windows

Linked PRs

@WolframAlph WolframAlph added the type-bug An unexpected behavior, bug, or error label Jan 11, 2025
@picnixz picnixz added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants