From f6b5eed47de2de13da94332231eb9c3f4769c78d Mon Sep 17 00:00:00 2001 From: Jonathan Dung Date: Sat, 21 Mar 2026 21:06:07 +0800 Subject: [PATCH] gh-146153: Use `frozendict` in pure python fallback for `curses.has_key` (#146154) Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com> --- Lib/curses/has_key.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Lib/curses/has_key.py b/Lib/curses/has_key.py index 4e37b480f133..3471b28cbbe0 100644 --- a/Lib/curses/has_key.py +++ b/Lib/curses/has_key.py @@ -7,7 +7,7 @@ import _curses # Table mapping curses keys to the terminfo capability name -_capability_names = { +_capability_names = frozendict({ _curses.KEY_A1: 'ka1', _curses.KEY_A3: 'ka3', _curses.KEY_B2: 'kb2', @@ -157,7 +157,7 @@ _capability_names = { _curses.KEY_SUSPEND: 'kspd', _curses.KEY_UNDO: 'kund', _curses.KEY_UP: 'kcuu1' - } + }) def has_key(ch): if isinstance(ch, str): @@ -170,7 +170,7 @@ def has_key(ch): #Check the current terminal description for that capability; #if present, return true, else return false. - if _curses.tigetstr( capability_name ): + if _curses.tigetstr(capability_name): return True else: return False -- 2.47.3