GDB copyright headers update after running GDB's copyright.py script.
[deliverable/binutils-gdb.git] / gdb / python / py-event.c
index 057bb2b8150a3fc27f2b88d517eb7f661d515b55..0dd94b4bb7e6885a7d98b3f77660d83be3b3b460 100644 (file)
@@ -1,6 +1,6 @@
 /* Python interface to inferior events.
 
-   Copyright (C) 2009-2012 Free Software Foundation, Inc.
+   Copyright (C) 2009-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -60,11 +60,11 @@ evpy_add_attribute (PyObject *event, char *name, PyObject *attr)
 
 /* Initialize the Python event code.  */
 
-void
+int
 gdbpy_initialize_event (void)
 {
-  gdbpy_initialize_event_generic (&event_object_type,
-                                  "Event");
+  return gdbpy_initialize_event_generic (&event_object_type,
+                                        "Event");
 }
 
 /* Initialize the given event type.  If BASE is not NULL it will
@@ -76,17 +76,9 @@ gdbpy_initialize_event_generic (PyTypeObject *type,
                                 char *name)
 {
   if (PyType_Ready (type) < 0)
-    goto fail;
-
-  Py_INCREF (type);
-  if (PyModule_AddObject (gdb_module, name, (PyObject *) type) < 0)
-    goto fail;
-
-  return 0;
-
-  fail:
-    Py_XDECREF (type);
     return -1;
+
+  return gdb_pymodule_addobject (gdb_module, name, (PyObject *) type);
 }
 
 
@@ -111,16 +103,23 @@ evpy_emit_event (PyObject *event,
   for (i = 0; i < PyList_Size (callback_list_copy); i++)
     {
       PyObject *func = PyList_GetItem (callback_list_copy, i);
+      PyObject *func_result;
 
       if (func == NULL)
        goto fail;
 
-      if (!PyObject_CallFunctionObjArgs (func, event, NULL))
+      func_result = PyObject_CallFunctionObjArgs (func, event, NULL);
+
+      if (func_result == 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 ();
        }
+      else
+       {
+         Py_DECREF (func_result);
+       }
     }
 
   Py_XDECREF (callback_list_copy);
This page took 0.024685 seconds and 4 git commands to generate.