Skip to content
Merged
Changes from 2 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
33 changes: 20 additions & 13 deletions Modules/_cursesmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,21 @@ _curses_window_getbkgd_impl(PyCursesWindowObject *self)
return (long) getbkgd(self->win);
}

static PyObject *
curses_check_signals_on_input_error(PyCursesWindowObject *self,
const char *curses_funcname,
const char *python_funcname)
{
assert(!PyErr_Occurred());
if (!PyErr_CheckSignals()) {
assert(!PyErr_Occurred());
cursesmodule_state *state = get_cursesmodule_state_by_win(self);
PyErr_Format(state->error, "%s() (called by %s()): no input",
curses_funcname, python_funcname);
}
return NULL;
}

/*[clinic input]
_curses.window.getch -> int

Expand Down Expand Up @@ -1731,13 +1746,9 @@ _curses_window_getkey_impl(PyCursesWindowObject *self, int group_right_1,
Py_END_ALLOW_THREADS

if (rtn == ERR) {
/* getch() returns ERR in nodelay mode */
PyErr_CheckSignals();
if (!PyErr_Occurred()) {
cursesmodule_state *state = get_cursesmodule_state_by_win(self);
const char *funcname = group_right_1 ? "mvwgetch" : "wgetch";
PyErr_Format(state->error, "getkey(): %s(): no input", funcname);
}
/* wgetch() returns ERR in nodelay mode */
const char *funcname = group_right_1 ? "mvwgetch" : "wgetch";
curses_check_signals_on_input_error(self, funcname, "getkey");
return NULL;
} else if (rtn <= 255) {
#ifdef NCURSES_VERSION_MAJOR
Expand Down Expand Up @@ -1791,13 +1802,9 @@ _curses_window_get_wch_impl(PyCursesWindowObject *self, int group_right_1,
Py_END_ALLOW_THREADS

if (ct == ERR) {
if (PyErr_CheckSignals())
return NULL;

/* get_wch() returns ERR in nodelay mode */
cursesmodule_state *state = get_cursesmodule_state_by_win(self);
/* wget_wch() returns ERR in nodelay mode */
const char *funcname = group_right_1 ? "mvwget_wch" : "wget_wch";
PyErr_Format(state->error, "get_wch(): %s(): no input", funcname);
curses_check_signals_on_input_error(self, funcname, "get_wch");
return NULL;
}
if (ct == KEY_CODE_YES)
Expand Down
Loading