Remove distracted red bar from IDLE for some SyntaxErrors
@terryjreedy がすでに取り組んでいます。
2022年6月17日 から。
評価
この issue はまだ評価されていません。
説明
Bug report
This may be more an distracting cosmetic issue than a true bug, but it is something that can be fixed easily.
As Raymond Hettinger mentioned a while ago on Twitter (https://twitter.com/raymondh/status/1501700903870468099), when a SyntaxError is raised and the location corresponds to the "\n" at the end of a line, a huge red highlighted region is shown at the end of the invalid line.
For example, type
from math
followed by enter. This red highlighted line will remain on the screen until another SyntaxError occurs.
Unlike cases where a SyntaxError highlights just a few characters pointing at a specific problem, this adds really no informative value, once the user starts entering some new code.
Your environment
I have reproduced this will IDLE on Windows 10 on all Python versions I have installed, from 3.6 to 3.11 inclusively.
Proposed fix
I have been able to fix this on a custom version of IDLE (friendly_idle) by doing the following:
In pyshell.ModifiedInterpreter.transfer_path which sets up some values at the beginning of a new process,
define the following:
self.error_at_end_of_line = False
In pyshell.ModifiedInterpreter.showsyntaxerror, add the last line shown below:
if lineno == 1:
pos = "iomark + %d chars" % (offset - 1)
else:
pos = "iomark linestart + %d lines + %d chars" % (lineno - 1, offset - 1)
self.error_at_end_of_line = text.get(pos) == "\n" # <-- add this
At the beginning of pyshell.ModifiedInterpreter.runsource, add the following:
if self.error_at_end_of_line:
self.error_at_end_of_line = False
self.tkconsole.text.tag_remove("ERROR", "1.0", "end")
If desired, I could do a pull request that would include these changes.
Linked PRs
- gh-157595
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 36k
- 平均マージ
- 1日 9時間
- マージ済み PR(30日)
- 558
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python/cpython のほかの issue
-
docs pending
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
stdlib type-feature
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
stdlib type-feature
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
build type-bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
stdlib topic-email type-feature
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
似ている issue
-
area/auth bug comp/agent P3 platform/discord type/security
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
NousResearch/hermes-agent#117848 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
bancolombia/sentinel#23 ·
-
test md オープンCI
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
langchain-ai/deepagents#6450 ·
-
bug client
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100