From: Andrew M. Kuchling Date: Tue, 2 Sep 2003 11:44:44 +0000 (+0000) Subject: [Patch #759208] Fix has_key emulation to not raise KeyError X-Git-Tag: v2.4a1~1663 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0ec5288d09e2ac3652c8a88f644417629ed1e759;p=python [Patch #759208] Fix has_key emulation to not raise KeyError --- diff --git a/Lib/curses/has_key.py b/Lib/curses/has_key.py index 728c614f20..cac0cd11c1 100644 --- a/Lib/curses/has_key.py +++ b/Lib/curses/has_key.py @@ -163,7 +163,9 @@ def has_key(ch): if type(ch) == type( '' ): ch = ord(ch) # Figure out the correct capability name for the keycode. - capability_name = _capability_names[ch] + capability_name = _capability_names.get(ch) + if capability_name is None: + return 0 #Check the current terminal description for that capability; #if present, return true, else return false.