From f5d7cc239e61e063e7bab783d55deb8e72210674 Mon Sep 17 00:00:00 2001 From: R David Murray Date: Tue, 19 Mar 2013 16:23:09 -0400 Subject: [PATCH] #8862: Fix curses cleanup with getchar is interrupted by a signal. I have no idea how one would write a test for this. Patch by July Tikhonov. --- Misc/NEWS | 2 ++ Modules/_cursesmodule.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS b/Misc/NEWS index 9a62a02bebe..4ebd699c448 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -233,6 +233,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 5e1afa9894a..d1dedb0bb0a 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -895,7 +895,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);