From: Michael Eager <eager@eagerm.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: [PATCH] PR14291: KeyboardInterrupt not caught for Python output
Date: Mon, 25 Jun 2012 12:33:00 -0000 [thread overview]
Message-ID: <4FE85A77.70809@eagerm.com> (raw)
http://sourceware.org/bugzilla/show_bug.cgi?id=14291
python
try:
for i in range(400):
print i
except KeyboardInterrupt:
print "caught interrupt"
end
Entering "q" at "q <return> to quit" results in the Python
program being prematurely terminated.
(BTW, I tried to add this to the test suite, but gdb_test_multiple
catches the "enter q <return>" prompt and fails the test.)
2012-06-25 Michael Eager <eager@eagercon.com>
* python/python.c (gdbpy_write): Check for interrupted
output.
Index: python/python.c
===================================================================
RCS file: /cvs/src/src/gdb/python/python.c,v
retrieving revision 1.90
diff -u -p -r1.90 python.c
--- python/python.c 18 May 2012 21:02:52 -0000 1.90
+++ python/python.c 25 Jun 2012 12:25:33 -0000
@@ -862,26 +862,31 @@ gdbpy_write (PyObject *self, PyObject *a
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;
}
--
Michael Eager eager@eagercon.com
1960 Park Blvd., Palo Alto, CA 94306 650-325-8077
next reply other threads:[~2012-06-25 12:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-25 12:33 Michael Eager [this message]
2012-06-25 15:26 ` Tom Tromey
2012-06-25 16:54 ` Michael Eager
2012-06-27 13:37 ` Tom Tromey
2012-06-27 14:06 ` Michael Eager
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FE85A77.70809@eagerm.com \
--to=eager@eagerm.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox