summaryrefslogtreecommitdiff
path: root/Modules/_cursesmodule.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-11-01 16:03:40 +0200
committerGitHub <noreply@github.com>2017-11-01 16:03:40 +0200
commit7e68790f3db75a893d5dd336e6201a63bc70212b (patch)
tree9b1e903a89d10dd46e60017332408da4f80e1871 /Modules/_cursesmodule.c
parentd1e34031f68a3c7523a5376575c87cd0fea2425c (diff)
downloadcpython-git-7e68790f3db75a893d5dd336e6201a63bc70212b.tar.gz
bpo-15037: Add a workaround for getkey() in curses for ncurses 5.7 and earlier. (#3826)
Skip a test for unget_wch()/get_wch() on OpenBSD since they are broken in ncurses 5.7.
Diffstat (limited to 'Modules/_cursesmodule.c')
-rw-r--r--Modules/_cursesmodule.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index 7962936966..1f6897a570 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -1163,8 +1163,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);