diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2017-11-01 14:38:35 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-11-01 14:38:35 (GMT) |
commit | 1f81ea85e8e20347ec396001e5b869d36fe38398 (patch) | |
tree | ae6c87feb639cb89135036aae06edea369f5db60 /Modules | |
parent | 2be9a31213e93e26a71150efaef1a975f8b9afec (diff) | |
download | cpython-1f81ea85e8e20347ec396001e5b869d36fe38398.zip cpython-1f81ea85e8e20347ec396001e5b869d36fe38398.tar.gz cpython-1f81ea85e8e20347ec396001e5b869d36fe38398.tar.bz2 |
bpo-15037: Add a workaround for getkey() in curses for ncurses 5.7 and earlier. (GH-3826) (#4218)
Skip a test for unget_wch()/get_wch() on OpenBSD since they are broken
in ncurses 5.7.
(cherry picked from commit 7e68790f3db75a893d5dd336e6201a63bc70212b)
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_cursesmodule.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index 4a1d08a..0e4cd53 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -1165,8 +1165,16 @@ PyCursesWindow_GetKey(PyCursesWindowObject *self, PyObject *args) if (!PyErr_Occurred()) PyErr_SetString(PyCursesError, "no input"); return NULL; - } else if (rtn<=255) { - return Py_BuildValue("C", rtn); + } else if (rtn <= 255) { +#ifdef NCURSES_VERSION_MAJOR +#if NCURSES_VERSION_MAJOR*100+NCURSES_VERSION_MINOR <= 507 + /* Work around a bug in ncurses 5.7 and earlier */ + if (rtn < 0) { + rtn += 256; + } +#endif +#endif + return PyUnicode_FromOrdinal(rtn); } else { const char *knp = keyname(rtn); return PyUnicode_FromString((knp == NULL) ? "" : knp); |