IDLE: ScrolledCanvas.zoom_height calls idlelib.zoomheight.zoom_height, which has not existed since 2019
まだ誰も着手していません。
評価
調査の方向性
Lib/idlelib/tree.py の ScrolledCanvas.zoom_height から始め、idlelib/zoomheight.py の ZoomHeight.zoom_height の実装と比較します。ツリーウィンドウで Alt-2 アクションを再現し、修正後の呼び出しで AttributeError が発生しなくなり、toplevel ウィンドウがその高さまでズームされることを確認します。
索引モデルが issue の本文から書いたものです。
説明
Bug report
idlelib.tree.ScrolledCanvas.zoom_height calls a module-level function that has not existed since 2019, so the binding raises as soon as it fires.
Where: Lib/idlelib/tree.py, ScrolledCanvas.zoom_height (line 459 on main), bound to <Alt-2> on the canvas:
def zoom_height(self, event):
zoomheight.zoom_height(self.master)
idlelib/zoomheight.py has had no module-level zoom_height since the Zoom Height rework (gh-81220, PRs #13576 and #13678, 2019): zooming is now ZoomHeight(editwin).zoom_height(), which only reads editwin.top.
Reproduce (3.13.5, but the call is the same on main):
>>> from idlelib import zoomheight
>>> zoomheight.zoom_height
AttributeError: module 'idlelib.zoomheight' has no attribute 'zoom_height'. Did you mean: 'ZoomHeight'?
Pressing Alt-2 in a tree window (Path Browser, Module Browser, the debugger's stack viewer) raises the same AttributeError out of the Tk callback.
Proposed fix — ZoomHeight needs only the toplevel window of what it zooms:
+from types import SimpleNamespace
+
from idlelib import zoomheight
@@
def zoom_height(self, event):
- zoomheight.zoom_height(self.master)
+ # ZoomHeight needs only the toplevel window of what it zooms.
+ top = self.canvas.winfo_toplevel()
+ zoomheight.ZoomHeight(SimpleNamespace(top=top)).zoom_height()
return "break"
Checked by calling ScrolledCanvas.zoom_height from main's sources against a stand-in toplevel: the current code raises AttributeError; the fixed code maximizes the window height (400x300+10+20 -> 400x760+10+0).
If a SimpleNamespace stand-in is not wanted here, ZoomHeight.zoom_height could instead take the toplevel directly; happy to send a PR either way.
Environment: Windows 11, CPython 3.13.5; the line is unchanged on main.
Found while auditing installed code with a verification tool I am building; the reproduction above was run on the version named, and the proposed fix was applied to a local copy and run as well. Report drafted with AI assistance.
Linked PRs
- gh-157772
- 主要言語
- 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