Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Lib/test/test_curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ def test_issue6243(self):
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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added a workaround for getkey() in curses for ncurses 5.7 and earlier.
12 changes: 10 additions & 2 deletions Modules/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1160,8 +1160,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;
#if defined(__NetBSD__)
Expand Down