From 68bcecd823d3c98539873389b0734ad3a40803e8 Mon Sep 17 00:00:00 2001 From: Ulf Magnusson Date: Sun, 12 Jan 2020 11:03:23 +0100 Subject: 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. --- menuconfig.py | 13 +++++++++---- 1 file 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) -- cgit v1.2.3