Remove comments from `find_assignment_target` result
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
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:
https://github.com/python/cpython/blob/22a442181d5f1ac496dac08e24fd852de404882f/Tools/cases_generator/analyzer.py#L457-L460
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
- gh-128743
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Tools/cases_generator/analyzer.py around analyze_deferred_refs at lines 457-460, where the issue identifies leading comments in lhs as the cause. Reproduce with Tools/cases_generator/tier1_generator.py and the bytecodes.c example; done means a comment before the assignment no longer triggers the PyStackRef_FromPyObjectNew() error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100