aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/tkinter
diff options
context:
space:
mode:
authorZhikang Yan <2951256653@qq.com>2025-01-13 23:54:46 +0800
committerGitHub <noreply@github.com>2025-01-13 15:54:46 +0000
commitda8825ea95a7096bb4f933d33b212a94ade10f6e (patch)
tree9b9bdccaf09eeee02ffdc12573d4e00d95cc839a /Lib/tkinter
parent402b91da87052878b4e7e8946ba91bdf4ee4bebe (diff)
downloadcpython-da8825ea95a7096bb4f933d33b212a94ade10f6e.tar.gz
cpython-da8825ea95a7096bb4f933d33b212a94ade10f6e.zip
gh-128562: Fix generation of the tkinter widget names (GH-128604)
There were possible conflicts if the widget class name ends with a digit.
Diffstat (limited to 'Lib/tkinter')
-rw-r--r--Lib/tkinter/__init__.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py
index d494c0c9687..0baed8b569e 100644
--- a/Lib/tkinter/__init__.py
+++ b/Lib/tkinter/__init__.py
@@ -2741,6 +2741,8 @@ class BaseWidget(Misc):
del cnf['name']
if not name:
name = self.__class__.__name__.lower()
+ if name[-1].isdigit():
+ name += "!" # Avoid duplication when calculating names below
if master._last_child_ids is None:
master._last_child_ids = {}
count = master._last_child_ids.get(name, 0) + 1