Include the opening brace's line in multiline f-string errors

オープン
#157,778 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
compilers

調査の方向性

提供された複数行 f-string の再現コードから始め、その診断結果を期待されるメッセージと比較します。対応する t-string のケースを確認し、置換フィールド内の有効な文字列が引き続き機能することを確認します。影響を受ける両方のエラーメッセージが開き波括弧の行を示し、有効な文字列を壊さないことが完了の条件です。リンクされた pull request はすでに一覧にあります。

索引モデルが issue の本文から書いたものです。

説明

interpreter-core type-feature

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
主要言語
Python
スター
77.2k
フォーク
36k
平均マージ
1日 9時間
マージ済み PR(30日)
558

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

python/cpython のほかの issue

python/cpython の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。