diff --git a/Misc/NEWS b/Misc/NEWS index fa5a50e93ea..11399bb5fba 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -289,6 +289,8 @@ Core and Builtins Library ------- +- Issue #8862: Fixed curses cleanup when getkey is interrputed by a signal. + - Issue #17443: impalib.IMAP4_stream was using the default unbuffered IO in subprocess, but the imap code assumes buffered IO. In Python2 this worked by accident. IMAP4_stream now explicitly uses buffered IO. diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index 4e1449bf69f..35f9fc15dae 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -1138,7 +1138,9 @@ PyCursesWindow_GetKey(PyCursesWindowObject *self, PyObject *args) } if (rtn == ERR) { /* getch() returns ERR in nodelay mode */ - PyErr_SetString(PyCursesError, "no input"); + PyErr_CheckSignals(); + if (!PyErr_Occurred()) + PyErr_SetString(PyCursesError, "no input"); return NULL; } else if (rtn<=255) { return Py_BuildValue("C", rtn);