RustPython / RustPython/Parser

Incorrect f-string parsing

未关闭
#88 1 条评论 4 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

bug
主要语言
Rust
星标
117
派生
38
平均合并
4 天 7 小时
30 天内合并 PR
1

描述

Originally reported as https://github.com/astral-sh/ruff/issues/5044:

Not the best string ever, but ruff doesn't handle it like Python

λ cat test.py
print(f"$N_{{img}}\in\{{0,1,2\}}$")
λ python test.py
$N_{img}\in\{0,1,2\}$
λ ruff check test.py --select F401
error: Failed to parse test.py:1:25: f-string: unterminated string

贡献指南

这个仓库没有索引到贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

使用提供的 test.py 内容重现该报告,并将 Python 的输出与 ruff check test.py --select F401 进行比较。跟踪此 f-string 的解析方式,并确保解析器接受转义的大括号和反斜杠,而不是报告字符串未终止。示例能够在不出现所报告错误的情况下完成解析,并且与 Python 的行为一致,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
python, rust
领域
compilers
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。