Deduplicate escape/quote scanning in f-string/t-string debug text handling
Open
Nobody has claimed this yet.
interpreter-core
topic-parser
type-refactor
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Parser/lexer/string.c has two copies of the same escape-and-quote scanning logic in _PyLexer_set_ftstring_expr (one loop to detect a comment, one to strip it). The two loops drifting apart is what caused gh-154711 / #154914. Follow-up: factor the shared scanning logic into a small helper so the two loops can't diverge again.
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 Parser/lexer/string.c at _PyLexer_set_ftstring_expr and compare its two escape-and-quote scanning loops: one detects a comment and the other strips it. Factor their shared scanning logic into a small helper, then verify both paths use it and no longer drift apart.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100