Include the opening brace's line in multiline f-string errors
未關閉
還沒有人認領這個 Issue。
interpreter-core
type-feature
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
An unclosed f-string replacement field can report an error on a later line, making the opening brace hard to find:
var = "abc"
a = f""" {var} extern "C" { """
b = """ string """
File "script.py", line 3
b = """ string """
^
SyntaxError: f-string: expecting '}'
The quotes after the second { start a string inside the replacement field. That string ends on line 3, and the final quotes start another string that is never closed.
The error should include the line number of the opening brace:
SyntaxError: f-string: expecting '}' to close '{' on line 2
The same problem affects t-strings. Valid strings inside replacement fields should continue to work.
Linked PRs
- gh-157779
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從提供的多行 f-string 重現程式碼開始,並將其診斷結果與預期訊息進行比較。檢查對應的 t-string 情況,並確認替換欄位中的有效字串仍然可以正常運作。完成的標準是:兩個受影響的錯誤訊息都指出左大括號所在的行,且不會導致有效字串回歸;一個已關聯的 pull request 已經列出。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- compilers
- Issue 類型
- 缺陷
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 35/100