python / python/cpython

IDLE: ScrolledCanvas.zoom_height calls idlelib.zoomheight.zoom_height, which has not existed since 2019

Abierto
#157,762 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

stdlib topic-IDLE type-bug
Lenguaje dominante
Python
Estrellas
77.2k
Forks
35.9k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

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 fixZoomHeight 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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con Lib/idlelib/tree.py en ScrolledCanvas.zoom_height y compáralo con la implementación de ZoomHeight.zoom_height de idlelib/zoomheight.py. Reproduce la acción Alt-2 en una ventana de árbol y verifica después que la llamada corregida ya no produzca AttributeError y haga zoom de la ventana toplevel a su altura.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
desktop
Tipo de issue
Error
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
30/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.