python / python/cpython

Deduplicate escape/quote scanning in f-string/t-string debug text handling

Open
#155,516 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.