Skip to content

Commit 68bcecd

Browse files
committed
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 ulfalizer/Kconfiglib#84. Needs more investigation, but I don't have a Mac handy. Based on ulfalizer/Kconfiglib#85, but with some more comments.
1 parent fa07831 commit 68bcecd

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

menuconfig.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3137,12 +3137,17 @@ def _is_num(name):
31373137

31383138

31393139
def _getch_compat(win):
3140-
# Uses get_wch() if available (Python 3.3+) and getch() otherwise. Also
3141-
# handles a PDCurses resizing quirk.
3140+
# Uses get_wch() if available (Python 3.3+) and getch() otherwise.
3141+
#
3142+
# Also falls back on getch() if get_wch() raises curses.error, to work
3143+
# around an issue when resizing the terminal on at least macOS Catalina.
3144+
# See https://github.com/ulfalizer/Kconfiglib/issues/84.
3145+
#
3146+
# Also handles a PDCurses resizing quirk.
31423147

3143-
if hasattr(win, "get_wch"):
3148+
try:
31443149
c = win.get_wch()
3145-
else:
3150+
except (AttributeError, curses.error):
31463151
c = win.getch()
31473152
if 0 <= c <= 255:
31483153
c = chr(c)

0 commit comments

Comments
 (0)