#8862: Fix curses cleanup with getchar is interrupted by a signal.
authorR David Murray <rdmurray@bitdance.com>
Tue, 19 Mar 2013 20:26:53 +0000 (16:26 -0400)
committerR David Murray <rdmurray@bitdance.com>
Tue, 19 Mar 2013 20:26:53 +0000 (16:26 -0400)
I have no idea how one would write a test for this.

Patch by July Tikhonov.

Misc/NEWS
Modules/_cursesmodule.c

index 5c3c6320f47a6c498d8931c5b1703d26faf9cc44..6b8cf1ff3c068d2b410ce06da65da4058ae97489 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -214,6 +214,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #8862: Fixed curses cleanup when getkey is interrputed by a signal.
+
 - Issue #9090: When a socket with a timeout fails with EWOULDBLOCK or EAGAIN,
   retry the select() loop instead of bailing out.  This is because select()
   can incorrectly report a socket as ready for reading (for example, if it
index 5f26c7fa81bb02289f2a65ecdf98c0cb8f87299b..b914e5f681970ac28c315f2c99fb06a6e151c5ad 100644 (file)
@@ -885,7 +885,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);