diff options
| author | Ulf Magnusson <ulfalizer@gmail.com> | 2019-06-05 13:20:44 +0200 |
|---|---|---|
| committer | Ulf Magnusson <ulfalizer@gmail.com> | 2019-06-06 04:21:19 +0200 |
| commit | c3162bec586619de935ac1d9801e4332cead9969 (patch) | |
| tree | d10fd7f56fa7fce53c2295465a11565f1aca93db | |
| parent | b2e211d34fea5ae8e88d9f35cc90ae80c534e38f (diff) | |
menuconfig: Only decode curses.erasechar() on Python 3
Avoids turning it into a Unicode string on Python 2, which gets messy
when strings are compared.
| -rwxr-xr-x | menuconfig.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/menuconfig.py b/menuconfig.py index c5ea23d..40689e8 100755 --- a/menuconfig.py +++ b/menuconfig.py @@ -957,10 +957,12 @@ def _init(): # Looking for this in addition to KEY_BACKSPACE (which is unreliable) makes # backspace work with TERM=vt100. That makes it likely to work in sane # environments. - # - # erasechar() returns a 'bytes' object. Since we use get_wch(), we need to - # decode it. Just give up and avoid crashing if it can't be decoded. - _ERASE_CHAR = curses.erasechar().decode("utf-8", "ignore") + _ERASE_CHAR = curses.erasechar() + if sys.version_info[0] >= 3: + # erasechar() returns a one-byte bytes object on Python 3. This sets + # _ERASE_CHAR to a blank string if it can't be decoded, which should be + # harmless. + _ERASE_CHAR = _ERASE_CHAR.decode("utf-8", "ignore") _init_styles() |
