summaryrefslogtreecommitdiff
path: root/gdb/python
diff options
context:
space:
mode:
authorMichael Eager <eager@eagercon.com>2012-06-25 16:53:20 +0000
committerMichael Eager <eager@eagercon.com>2012-06-25 16:53:20 +0000
commitadb4fe3b309bace3ceb2c0e305f7faf41eb708a6 (patch)
tree779190735ee9eb67711eb485efc21f309182a68e /gdb/python
parent944a90619c1efc9acf4a2cb420936999baecdee0 (diff)
downloadbinutils-gdb-adb4fe3b309bace3ceb2c0e305f7faf41eb708a6.tar.gz
PR14291: KeyboardInterrupt not caught for Python output
Diffstat (limited to 'gdb/python')
-rw-r--r--gdb/python/python.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/gdb/python/python.c b/gdb/python/python.c
index 19eb7b546af..c66efe465e7 100644
--- a/gdb/python/python.c
+++ b/gdb/python/python.c
@@ -862,26 +862,31 @@ gdbpy_write (PyObject *self, PyObject *args, PyObject *kw)
const char *arg;
static char *keywords[] = {"text", "stream", NULL };
int stream_type = 0;
+ volatile struct gdb_exception except;
if (! PyArg_ParseTupleAndKeywords (args, kw, "s|i", keywords, &arg,
&stream_type))
return NULL;
- switch (stream_type)
+ TRY_CATCH (except, RETURN_MASK_ALL)
{
- case 1:
- {
- fprintf_filtered (gdb_stderr, "%s", arg);
- break;
- }
- case 2:
- {
- fprintf_filtered (gdb_stdlog, "%s", arg);
- break;
- }
- default:
- fprintf_filtered (gdb_stdout, "%s", arg);
+ switch (stream_type)
+ {
+ case 1:
+ {
+ fprintf_filtered (gdb_stderr, "%s", arg);
+ break;
+ }
+ case 2:
+ {
+ fprintf_filtered (gdb_stdlog, "%s", arg);
+ break;
+ }
+ default:
+ fprintf_filtered (gdb_stdout, "%s", arg);
+ }
}
+ GDB_PY_HANDLE_EXCEPTION (except);
Py_RETURN_NONE;
}