From: Tom Tromey <tromey@redhat.com>
To: Project Archer <archer@sourceware.org>
Subject: [inferior events] cleanups in evpy_emit_event
Date: Tue, 14 Dec 2010 21:35:00 -0000 [thread overview]
Message-ID: <m3r5dkox5o.fsf@fleche.redhat.com> (raw)
Sami --
This patch cleans up evpy_emit_event:
* It isn't ok to call error here
* Now we check all Python operations
* Now we call gdbpy_print_stack on error. This seems correct since
we don't actually want errors here to propagate -- just to be printed
if the user asked for that
* Now objects are properly deallocated
I needed this while debugging an event listener of mine.
Ok to push?
Tom
@@ -137,15 +145,31 @@ evpy_emit_event (event_object *event)
a notification. */
callback_list_copy = copy_py_list (callback_list);
if (!callback_list_copy)
- error(_("Cannot copy callback list."));
-
- args_tuple = PyTuple_New ((Py_ssize_t) 1);
- PyTuple_SetItem (args_tuple, (Py_ssize_t) 0, (PyObject *) event);
+ goto fail;
for (i = 0; i < PyList_Size (callback_list_copy); i++)
{
- PyObject_CallObject (PyList_GET_ITEM (callback_list_copy, i), args_tuple);
+ PyObject *func = PyList_GetItem (callback_list_copy, i);
+
+ if (func == NULL)
+ goto fail;
+
+ if (!PyObject_CallFunctionObjArgs (func, event_obj, NULL))
+ {
+ /* Print the trace here, but keep going -- we want to try to
+ call all of the callbacks even if one is broken. */
+ gdbpy_print_stack ();
+ }
}
+
+ Py_XDECREF (callback_list_copy);
+ Py_XDECREF (event_obj);
+ return;
+
+ fail:
+ gdbpy_print_stack ();
+ Py_XDECREF (callback_list_copy);
+ Py_XDECREF (event_obj);
}
static PyGetSetDef event_object_getset[] =
next reply other threads:[~2010-12-14 21:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-14 21:35 Tom Tromey [this message]
2010-12-15 15:43 ` sami wagiaalla
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=m3r5dkox5o.fsf@fleche.redhat.com \
--to=tromey@redhat.com \
--cc=archer@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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).