bt2: make bt2.Error wrap current thread's error
[babeltrace.git] / src / bindings / python / bt2 / bt2 / native_bt_trace.i
index 8fcc5db9319371e2f8c1a1d6934d03eed30a1d44..34530299959ce3caa707a097db2854f1405b38e6 100644 (file)
@@ -40,36 +40,32 @@ trace_destroyed_listener(const bt_trace *trace, void *py_callable)
        }
 
        py_res = PyObject_CallFunction(py_callable, "(O)", py_trace_ptr);
-       if (py_res != NULL) {
+       if (py_res) {
                BT_ASSERT(py_res == Py_None);
        } else {
-               bt2_py_loge_exception();
+               loge_exception("Trace's destruction listener (Python)");
        }
 
        Py_DECREF(py_trace_ptr);
        Py_XDECREF(py_res);
 }
 
-uint64_t bt_py3_trace_add_destruction_listener(bt_trace *trace, PyObject *py_callable)
+int bt_bt2_trace_add_destruction_listener(bt_trace *trace,
+               PyObject *py_callable, uint64_t *id)
 {
-       uint64_t id = UINT64_C(-1);
-       bt_trace_status status;
+       bt_trace_add_listener_status status;
 
        BT_ASSERT(trace);
        BT_ASSERT(py_callable);
-
        status = bt_trace_add_destruction_listener(
-               trace, trace_destroyed_listener, py_callable, &id);
-       if (status != BT_TRACE_STATUS_OK) {
-               BT_LOGF_STR("Failed to add trace destruction listener.");
-               abort();
+               trace, trace_destroyed_listener, py_callable, id);
+       if (status == __BT_FUNC_STATUS_OK) {
+               Py_INCREF(py_callable);
        }
 
-       Py_INCREF(py_callable);
-
-       return id;
+       return status;
 }
 %}
 
-uint64_t bt_py3_trace_add_destruction_listener(bt_trace *trace,
-       PyObject *py_callable);
+int bt_bt2_trace_add_destruction_listener(bt_trace *trace,
+               PyObject *py_callable, uint64_t *id);
This page took 0.025129 seconds and 4 git commands to generate.