certain f/t-string expressions not copied correctly to debug str or interpolations
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
Bug report
Bug description:
The function set_ftstring_expr() in Parser/lexer/lexer.c does not currently copy certain f/t-string expressions correctly. It has problems with non-coding quotes (escaped or in comments) and nested f/t-strings. This applies to both self-documenting debug expressions and more importantly to t-string interpolation expressions.
For example, the # comment below should not print:
>>> print(f'''{'\'' # comment
... =}''')
'\'' # comment
="'"
Copied expression terminates early:
>>> print(f'{(f'''
... # not comment A
... { # comment B '
... 3 # comment C
... * 2}''', '\n# not comment D\n6')=}')
(f'''
# not comment A
{ # comment B '
3
* 2}''', '\n('\n# not comment A\n6', '\n# not comment D\n6')
It does not appear the function was written to handle nested f/t-strings and the string quote handling does not take into account escaped quotes.
CPython versions tested on:
3.14, CPython main branch
Operating systems tested on:
Linux
Linked PRs
- gh-141274
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne in Parser/lexer/lexer.c bei set_ftstring_expr() und reproduziere die Beispiele mit escapten Anführungszeichen, Kommentaren und verschachtelten f/t-Strings aus dem Bericht. Verfolge, wie Ausdrücke für die Debug-Ausgabe und die Interpolation von t-Strings kopiert werden, und überprüfe anschließend, dass Anführungszeichen enthaltender Text und Kommentare das Kopieren nicht vorzeitig beenden und dass die gezeigten Ausgaben korrigiert sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- c
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 25/100