* [inferior events] cleanups in evpy_emit_event
@ 2010-12-14 21:35 Tom Tromey
2010-12-15 15:43 ` sami wagiaalla
0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2010-12-14 21:35 UTC (permalink / raw)
To: Project Archer
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[] =
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [inferior events] cleanups in evpy_emit_event
2010-12-14 21:35 [inferior events] cleanups in evpy_emit_event Tom Tromey
@ 2010-12-15 15:43 ` sami wagiaalla
0 siblings, 0 replies; 2+ messages in thread
From: sami wagiaalla @ 2010-12-15 15:43 UTC (permalink / raw)
To: archer
On 12/14/2010 04:35 PM, Tom Tromey wrote:
> 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
>
Great! Thanks for the cleanup. I didn't really know how to report an
error but not propagate it.
> Ok to push?
Yes.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-12-15 15:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-14 21:35 [inferior events] cleanups in evpy_emit_event Tom Tromey
2010-12-15 15:43 ` sami wagiaalla
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).