From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19650 invoked by alias); 14 Dec 2010 21:35:42 -0000 Mailing-List: contact archer-help@sourceware.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Subscribe: List-Id: Received: (qmail 19551 invoked by uid 22791); 14 Dec 2010 21:35:41 -0000 X-SWARE-Spam-Status: No, hits=-6.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org From: Tom Tromey To: Project Archer Subject: [inferior events] cleanups in evpy_emit_event Date: Tue, 14 Dec 2010 21:35:00 -0000 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-SW-Source: 2010-q4/txt/msg00034.txt.bz2 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[] =