certain f/t-string expressions not copied correctly to debug str or interpolations
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 77.2k
- 派生
- 36k
- PR 合并指标
- PR 指标待抓取
描述
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Parser/lexer/lexer.c 中的 set_ftstring_expr() 开始,重现报告中转义引号、注释和嵌套 f/t-string 的示例。跟踪表达式如何为调试输出和 t-string 插值而复制,然后验证带引号的文本和注释不会使复制提前终止,并确认所示输出已得到修正。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- c
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 25/100