self.stdscr.getkey()
@requires_curses_func('unget_wch')
+ # XXX Remove the decorator when ncurses on OpenBSD be updated
+ @unittest.skipIf(sys.platform.startswith("openbsd"),
+ "OpenBSD's curses (v.5.7) has bugs")
def test_unget_wch(self):
stdscr = self.stdscr
encoding = stdscr.encoding
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);