Skip to content

Commit

Permalink
menuconfig: Work around crash on resize on some macOS systems
Browse files Browse the repository at this point in the history
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 #84. Needs more
investigation, but I don't have a Mac handy.

Based on #85, but with some
more comments.
  • Loading branch information
ulfalizer committed Jan 12, 2020
1 parent fa07831 commit 68bcecd
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions menuconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 68bcecd

Please sign in to comment.