From c468a7fbd7235e2bb3b133e8663a3611e6758f12 Mon Sep 17 00:00:00 2001 From: Amin Alaee Date: Sat, 8 Aug 2026 09:52:25 +0200 Subject: [PATCH 1/2] [tkinter] Add iter = None to Misc, Image, and Font for Python 3.15 --- stdlib/@tests/stubtest_allowlists/py315.txt | 3 --- stdlib/tkinter/__init__.pyi | 6 ++++++ stdlib/tkinter/font.pyi | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/stdlib/@tests/stubtest_allowlists/py315.txt b/stdlib/@tests/stubtest_allowlists/py315.txt index fcd88edaf791..846657842ce8 100644 --- a/stdlib/@tests/stubtest_allowlists/py315.txt +++ b/stdlib/@tests/stubtest_allowlists/py315.txt @@ -29,9 +29,6 @@ importlib.resources._common.package_to_anchor mailbox._ProxyFile.__class_getitem__ multiprocessing.process.BaseProcess.__init__ threading.Condition.locked -tkinter.Image.__iter__ -tkinter.Misc.__iter__ -tkinter.font.Font.__iter__ # ============================================================= # Allowlist entries that cannot or should not be fixed; >= 3.15 diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 681c6ddba546..0c1743ccb88f 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -390,6 +390,9 @@ class Misc: master: Misc | None tk: _tkinter.TkappType children: dict[str, Widget] + if sys.version_info >= (3, 15): + __iter__: ClassVar[None] + def destroy(self) -> None: ... def deletecommand(self, name: str) -> None: ... def tk_strictMotif(self, boolean=None): ... @@ -3939,6 +3942,9 @@ class _PhotoImageLike(_Image): ... class Image(_Image): name: Incomplete tk: _tkinter.TkappType + if sys.version_info >= (3, 15): + __iter__: ClassVar[None] + def __init__(self, imgtype, name=None, cnf={}, master: Misc | _tkinter.TkappType | None = None, **kw) -> None: ... def __del__(self) -> None: ... def __setitem__(self, key, value) -> None: ... diff --git a/stdlib/tkinter/font.pyi b/stdlib/tkinter/font.pyi index d9e0b1315590..4d169740b856 100644 --- a/stdlib/tkinter/font.pyi +++ b/stdlib/tkinter/font.pyi @@ -1,5 +1,6 @@ import _tkinter import itertools +import sys import tkinter from typing import Any, ClassVar, Final, Literal, TypeAlias, TypedDict, overload, type_check_only from typing_extensions import Unpack @@ -41,6 +42,8 @@ class _MetricsDict(TypedDict): class Font: name: str delete_font: bool + if sys.version_info >= (3, 15): + __iter__: ClassVar[None] counter: ClassVar[itertools.count[int]] # undocumented def __init__( self, From bde42523bfeb5ff5fb78648f4d2a69cc234bd2b2 Mon Sep 17 00:00:00 2001 From: Akuli Date: Sun, 9 Aug 2026 18:33:05 +0300 Subject: [PATCH 2/2] Add short comments Co-authored-by: Amin Alaee --- stdlib/tkinter/__init__.pyi | 4 ++-- stdlib/tkinter/font.pyi | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index 0c1743ccb88f..a33f30adcbb9 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -391,7 +391,7 @@ class Misc: tk: _tkinter.TkappType children: dict[str, Widget] if sys.version_info >= (3, 15): - __iter__: ClassVar[None] + __iter__: ClassVar[None] # prevent using __getitem__ for iteration def destroy(self) -> None: ... def deletecommand(self, name: str) -> None: ... @@ -3943,7 +3943,7 @@ class Image(_Image): name: Incomplete tk: _tkinter.TkappType if sys.version_info >= (3, 15): - __iter__: ClassVar[None] + __iter__: ClassVar[None] # prevent using __getitem__ for iteration def __init__(self, imgtype, name=None, cnf={}, master: Misc | _tkinter.TkappType | None = None, **kw) -> None: ... def __del__(self) -> None: ... diff --git a/stdlib/tkinter/font.pyi b/stdlib/tkinter/font.pyi index 4d169740b856..72552eb8e251 100644 --- a/stdlib/tkinter/font.pyi +++ b/stdlib/tkinter/font.pyi @@ -43,7 +43,7 @@ class Font: name: str delete_font: bool if sys.version_info >= (3, 15): - __iter__: ClassVar[None] + __iter__: ClassVar[None] # prevent using __getitem__ for iteration counter: ClassVar[itertools.count[int]] # undocumented def __init__( self,