summaryrefslogtreecommitdiff
path: root/menuconfig.py
diff options
context:
space:
mode:
authorUlf Magnusson <ulfalizer@gmail.com>2020-01-12 11:03:23 +0100
committerUlf Magnusson <ulfalizer@gmail.com>2020-01-12 15:39:13 +0100
commit68bcecd823d3c98539873389b0734ad3a40803e8 (patch)
tree772cc188695f2dcc5b66f4182fb18895d3304805 /menuconfig.py
parentfa0783115466c35f52b226317cc26903f918a8ce (diff)
menuconfig: Work around crash on resize on some macOS systems
get_wch() has started raising curses.error when resizing the terminal on some macOS Python installations. Work around for now by falling back on getch(), which still works. See https://github.com/ulfalizer/Kconfiglib/issues/84. Needs more investigation, but I don't have a Mac handy. Based on https://github.com/ulfalizer/Kconfiglib/pull/85, but with some more comments.
Diffstat (limited to 'menuconfig.py')
-rwxr-xr-xmenuconfig.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/menuconfig.py b/menuconfig.py
index 8070816..beb4cde 100755
--- a/menuconfig.py
+++ b/menuconfig.py
@@ -3137,12 +3137,17 @@ def _is_num(name):
def _getch_compat(win):
- # Uses get_wch() if available (Python 3.3+) and getch() otherwise. Also
- # handles a PDCurses resizing quirk.
+ # Uses get_wch() if available (Python 3.3+) and getch() otherwise.
+ #
+ # Also falls back on getch() if get_wch() raises curses.error, to work
+ # around an issue when resizing the terminal on at least macOS Catalina.
+ # See https://github.com/ulfalizer/Kconfiglib/issues/84.
+ #
+ # Also handles a PDCurses resizing quirk.
- if hasattr(win, "get_wch"):
+ try:
c = win.get_wch()
- else:
+ except (AttributeError, curses.error):
c = win.getch()
if 0 <= c <= 255:
c = chr(c)