From 34dc7b08281f148a6a8b59402edf8a51f8199aae Mon Sep 17 00:00:00 2001 From: Ethan Furman Date: Tue, 22 Sep 2020 08:01:17 -0700 Subject: [PATCH 1/2] bpo-41817: use new StrEnum to ensure all members are strings (GH-22348) * use new StrEnum to ensure all members are strings (cherry picked from commit ea0711a9f9f207d6d4ca037d90de6ec60db131b0) Co-authored-by: Ethan Furman --- Lib/tkinter/__init__.py | 14 +++++++------- .../2020-09-22-00-23-30.bpo-41817.bnh-VG.rst | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2020-09-22-00-23-30.bpo-41817.bnh-VG.rst diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py index 9d3bf4d49298f9..cad40fd58963ff 100644 --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -144,12 +144,12 @@ def _splitdict(tk, v, cut_minus=True, conv=None): return dict -class EventType(str, enum.Enum): +class EventType(enum.StrEnum): KeyPress = '2' - Key = KeyPress, + Key = KeyPress KeyRelease = '3' ButtonPress = '4' - Button = ButtonPress, + Button = ButtonPress ButtonRelease = '5' Motion = '6' Enter = '7' @@ -180,10 +180,10 @@ class EventType(str, enum.Enum): Colormap = '32' ClientMessage = '33' # undocumented Mapping = '34' # undocumented - VirtualEvent = '35', # undocumented - Activate = '36', - Deactivate = '37', - MouseWheel = '38', + VirtualEvent = '35' # undocumented + Activate = '36' + Deactivate = '37' + MouseWheel = '38' def __str__(self): return self.name diff --git a/Misc/NEWS.d/next/Library/2020-09-22-00-23-30.bpo-41817.bnh-VG.rst b/Misc/NEWS.d/next/Library/2020-09-22-00-23-30.bpo-41817.bnh-VG.rst new file mode 100644 index 00000000000000..6a634bb613260b --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-09-22-00-23-30.bpo-41817.bnh-VG.rst @@ -0,0 +1 @@ +fix `tkinter.EventType` Enum so all members are strings, and none are tuples From 0c13bb35e75c7271c80a449bdf8e6ad237bd2fd4 Mon Sep 17 00:00:00 2001 From: Ethan Furman Date: Tue, 22 Sep 2020 10:36:37 -0700 Subject: [PATCH 2/2] fix `EventType` bases `StrEnum` does not exist in 3.8, so use original `(str, enum.Enum)` bases. --- Lib/tkinter/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/tkinter/__init__.py b/Lib/tkinter/__init__.py index cad40fd58963ff..479eb016da7f0a 100644 --- a/Lib/tkinter/__init__.py +++ b/Lib/tkinter/__init__.py @@ -144,7 +144,7 @@ def _splitdict(tk, v, cut_minus=True, conv=None): return dict -class EventType(enum.StrEnum): +class EventType(str, enum.Enum): KeyPress = '2' Key = KeyPress KeyRelease = '3'