lib: add bt_{graph,query_executor}_add_interrupter()
[babeltrace.git] / src / bindings / python / bt2 / bt2 / native_bt_component_class.i
index 8219040dbc054009a64f99edd287975a9d9874c6..63dcc0ba29378f5e3612297fef2b6841364ea6da 100644 (file)
@@ -22,6 +22,7 @@
  * THE SOFTWARE.
  */
 
+%include <babeltrace2/graph/component-class.h>
 %include <babeltrace2/graph/component-class-const.h>
 %include <babeltrace2/graph/component-class-source-const.h>
 %include <babeltrace2/graph/component-class-source.h>
@@ -42,7 +43,7 @@
  * to create a user Python component anyway.
  *
  * This hash table is written to when a user-defined Python component
- * class is created by one of the bt_py3_component_class_*_create()
+ * class is created by one of the bt_bt2_component_class_*_create()
  * functions.
  *
  * This function is read from when a user calls bt_component_create()
@@ -93,14 +94,14 @@ PyObject *lookup_cc_ptr_to_py_cls(const bt_component_class *bt_cc)
 
 static PyObject *py_mod_bt2 = NULL;
 static PyObject *py_mod_bt2_exc_error_type = NULL;
+static PyObject *py_mod_bt2_exc_memory_error = NULL;
 static PyObject *py_mod_bt2_exc_try_again_type = NULL;
 static PyObject *py_mod_bt2_exc_stop_type = NULL;
-static PyObject *py_mod_bt2_exc_msg_iter_canceled_type = NULL;
-static PyObject *py_mod_bt2_exc_invalid_query_object_type = NULL;
-static PyObject *py_mod_bt2_exc_invalid_query_params_type = NULL;
+static PyObject *py_mod_bt2_exc_invalid_object_type = NULL;
+static PyObject *py_mod_bt2_exc_invalid_params_type = NULL;
 
 static
-void bt_py3_cc_init_from_bt2(void)
+void bt_bt2_cc_init_from_bt2(void)
 {
        /*
         * This is called once the bt2 package is loaded.
@@ -113,30 +114,33 @@ void bt_py3_cc_init_from_bt2(void)
        py_mod_bt2 = PyImport_ImportModule("bt2");
        BT_ASSERT(py_mod_bt2);
        py_mod_bt2_exc_error_type =
-               PyObject_GetAttrString(py_mod_bt2, "Error");
+               PyObject_GetAttrString(py_mod_bt2, "_Error");
        BT_ASSERT(py_mod_bt2_exc_error_type);
+       py_mod_bt2_exc_memory_error =
+               PyObject_GetAttrString(py_mod_bt2, "_MemoryError");
+       BT_ASSERT(py_mod_bt2_exc_memory_error);
        py_mod_bt2_exc_try_again_type =
                PyObject_GetAttrString(py_mod_bt2, "TryAgain");
        BT_ASSERT(py_mod_bt2_exc_try_again_type);
        py_mod_bt2_exc_stop_type =
                PyObject_GetAttrString(py_mod_bt2, "Stop");
        BT_ASSERT(py_mod_bt2_exc_stop_type);
-       py_mod_bt2_exc_invalid_query_object_type =
-               PyObject_GetAttrString(py_mod_bt2, "InvalidQueryObject");
-       BT_ASSERT(py_mod_bt2_exc_invalid_query_object_type);
-       py_mod_bt2_exc_invalid_query_params_type =
-               PyObject_GetAttrString(py_mod_bt2, "InvalidQueryParams");
-       BT_ASSERT(py_mod_bt2_exc_invalid_query_params_type);
+       py_mod_bt2_exc_invalid_object_type =
+               PyObject_GetAttrString(py_mod_bt2, "InvalidObject");
+       BT_ASSERT(py_mod_bt2_exc_invalid_object_type);
+       py_mod_bt2_exc_invalid_params_type =
+               PyObject_GetAttrString(py_mod_bt2, "InvalidParams");
+       BT_ASSERT(py_mod_bt2_exc_invalid_params_type);
 }
 
 static
-void bt_py3_cc_exit_handler(void)
+void bt_bt2_cc_exit_handler(void)
 {
        /*
         * This is an exit handler (set by the bt2 package).
         *
         * We only give back the references that we took in
-        * bt_py3_cc_init_from_bt2() here. The global variables continue
+        * bt_bt2_cc_init_from_bt2() here. The global variables continue
         * to exist for the code of this file, but they are now borrowed
         * references. If this code is executed, it means that somehow
         * the modules are still loaded, so it should be safe to use
@@ -149,9 +153,8 @@ void bt_py3_cc_exit_handler(void)
        Py_XDECREF(py_mod_bt2_exc_error_type);
        Py_XDECREF(py_mod_bt2_exc_try_again_type);
        Py_XDECREF(py_mod_bt2_exc_stop_type);
-       Py_XDECREF(py_mod_bt2_exc_msg_iter_canceled_type);
-       Py_XDECREF(py_mod_bt2_exc_invalid_query_object_type);
-       Py_XDECREF(py_mod_bt2_exc_invalid_query_params_type);
+       Py_XDECREF(py_mod_bt2_exc_invalid_object_type);
+       Py_XDECREF(py_mod_bt2_exc_invalid_params_type);
 }
 
 
@@ -159,7 +162,7 @@ void bt_py3_cc_exit_handler(void)
 
 __attribute__((destructor))
 static
-void bt_py3_native_comp_class_dtor(void) {
+void native_comp_class_dtor(void) {
        /* Destroy component class association hash table */
        if (bt_cc_ptr_to_py_cls) {
                BT_LOGD_STR("Destroying native component class to Python component class hash table.");
@@ -168,82 +171,215 @@ void bt_py3_native_comp_class_dtor(void) {
 }
 
 static
-void bt2_py_loge_exception(void)
+void restore_current_thread_error_and_append_exception_chain_recursive(
+               PyObject *py_exc_value,
+               bt_self_component_class *self_component_class,
+               bt_self_component *self_component,
+               bt_self_message_iterator *self_message_iterator,
+               const char *module_name)
 {
-       GString *gstr;
+       PyObject *py_exc_cause_value;
+       PyObject *py_exc_type = NULL;
+       PyObject *py_exc_tb = NULL;
+       GString *gstr = NULL;
+
+       /* If this exception has a cause, handle that one first. */
+       py_exc_cause_value = PyException_GetCause(py_exc_value);
+       if (py_exc_cause_value) {
+               restore_current_thread_error_and_append_exception_chain_recursive(
+                       py_exc_cause_value, self_component_class,
+                       self_component, self_message_iterator, module_name);
+       }
+
+       /*
+        * If the raised exception is a bt2._Error, restore the wrapped error.
+        */
+       if (PyErr_GivenExceptionMatches(py_exc_value, py_mod_bt2_exc_error_type)) {
+               PyObject *py_error_swig_ptr;
+               const bt_error *error;
+               int ret;
+
+               /*
+                * We never raise a bt2._Error with a cause: it should be the
+                * end of the chain.
+                */
+               BT_ASSERT(!py_exc_cause_value);
+
+               /*
+                * We steal the error object from the exception, to move
+                * it back as the current thread's error.
+                */
+               py_error_swig_ptr = PyObject_GetAttrString(py_exc_value, "_ptr");
+               BT_ASSERT(py_error_swig_ptr);
+
+               ret = PyObject_SetAttrString(py_exc_value, "_ptr", Py_None);
+               BT_ASSERT(ret == 0);
+
+               ret = SWIG_ConvertPtr(py_error_swig_ptr, (void **) &error,
+                       SWIGTYPE_p_bt_error, 0);
+               BT_ASSERT(ret == 0);
+
+               BT_CURRENT_THREAD_MOVE_ERROR_AND_RESET(error);
+
+               Py_DECREF(py_error_swig_ptr);
+       }
+
+       py_exc_type = PyObject_Type(py_exc_value);
+       py_exc_tb = PyException_GetTraceback(py_exc_value);
 
-       BT_ASSERT(PyErr_Occurred() != NULL);
-       gstr = bt_py_common_format_exception(BT_LOG_OUTPUT_LEVEL);
+       gstr = bt_py_common_format_exception(py_exc_type, py_exc_value,
+                       py_exc_tb, BT_LOG_OUTPUT_LEVEL, false);
        if (!gstr) {
-               /* bt_py_common_format_exception() logs errors */
+               /* bt_py_common_format_exception has already warned. */
                goto end;
        }
 
-       BT_LOGE_STR(gstr->str);
+       if (self_component_class) {
+               BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT_CLASS(
+                       self_component_class, "%s", gstr->str);
+       } else if (self_component) {
+               BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_COMPONENT(
+                       self_component, "%s", gstr->str);
+       } else if (self_message_iterator) {
+               BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_MESSAGE_ITERATOR(
+                       self_message_iterator, "%s", gstr->str);
+       } else {
+               BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_UNKNOWN(
+                       module_name, "%s", gstr->str);
+       }
 
 end:
        if (gstr) {
                g_string_free(gstr, TRUE);
        }
+
+       Py_XDECREF(py_exc_cause_value);
+       Py_XDECREF(py_exc_type);
+       Py_XDECREF(py_exc_tb);
 }
 
+/*
+ * If you have the following code:
+ *
+ * try:
+ *     try:
+ *         something_that_raises_bt2_error()
+ *     except bt2._Error as e1:
+ *         raise ValueError from e1
+ * except ValueError as e2:
+ *     raise TypeError from e2
+ *
+ * We will have the following exception chain:
+ *
+ *     TypeError -> ValueError -> bt2._Error
+ *
+ * Where the TypeError is the current exception (obtained from PyErr_Fetch).
+ *
+ * The bt2._Error contains a `struct bt_error *` that used to be the current
+ * thread's error, at the moment the exception was raised.
+ *
+ * This function gets to the bt2._Error and restores the wrapped
+ * `struct bt_error *` as the current thread's error.
+ *
+ * Then, for each exception in the chain, starting with the oldest one, it adds
+ * an error cause to the current thread's error.
+ */
 static
-bt_self_component_status bt_py3_exc_to_self_component_status(void)
+void restore_bt_error_and_append_current_exception_chain(
+               bt_self_component_class *self_component_class,
+               bt_self_component *self_component,
+               bt_self_message_iterator *self_message_iterator,
+               const char *module_name)
 {
-       bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
-       PyObject *exc = PyErr_Occurred();
+       BT_ASSERT(PyErr_Occurred());
 
-       if (!exc) {
-               goto end;
-       }
+       /* Used to access and restore the current exception. */
+       PyObject *py_exc_type;
+       PyObject *py_exc_value;
+       PyObject *py_exc_tb;
 
-       if (PyErr_GivenExceptionMatches(exc,
-                       py_mod_bt2_exc_try_again_type)) {
-               status = BT_SELF_COMPONENT_STATUS_AGAIN;
-       } else if (PyErr_GivenExceptionMatches(exc,
-                       py_mod_bt2_exc_stop_type)) {
-               status = BT_SELF_COMPONENT_STATUS_END;
-       } else {
-               bt2_py_loge_exception();
-               status = BT_SELF_COMPONENT_STATUS_ERROR;
-       }
+       /* Fetch and normalize the Python exception. */
+       PyErr_Fetch(&py_exc_type, &py_exc_value, &py_exc_tb);
+       PyErr_NormalizeException(&py_exc_type, &py_exc_value, &py_exc_tb);
+       BT_ASSERT(py_exc_type);
+       BT_ASSERT(py_exc_value);
+       BT_ASSERT(py_exc_tb);
 
-end:
-       PyErr_Clear();
-       return status;
-}
+       /*
+        * Set the exception's traceback so it's possible to get it using
+        * PyException_GetTraceback in
+        * restore_current_thread_error_and_append_exception_chain_recursive.
+        */
+       PyException_SetTraceback(py_exc_value, py_exc_tb);
 
-/* Component class proxy methods (delegate to the attached Python object) */
+       restore_current_thread_error_and_append_exception_chain_recursive(py_exc_value,
+               self_component_class, self_component, self_message_iterator,
+               module_name);
 
-static
-bt_self_message_iterator_status bt_py3_exc_to_self_message_iterator_status(void)
+       PyErr_Restore(py_exc_type, py_exc_value, py_exc_tb);
+}
+
+static inline
+void log_exception_and_maybe_append_error(int log_level,
+               bool append_error,
+               bt_self_component_class *self_component_class,
+               bt_self_component *self_component,
+               bt_self_message_iterator *self_message_iterator,
+               const char *module_name)
 {
-       enum bt_self_message_iterator_status status =
-               BT_SELF_MESSAGE_ITERATOR_STATUS_OK;
-       PyObject *exc = PyErr_Occurred();
+       GString *gstr;
 
-       if (!exc) {
+       BT_ASSERT(PyErr_Occurred());
+       gstr = bt_py_common_format_current_exception(BT_LOG_OUTPUT_LEVEL);
+       if (!gstr) {
+               /* bt_py_common_format_current_exception() logs errors */
                goto end;
        }
 
-       if (PyErr_GivenExceptionMatches(exc, py_mod_bt2_exc_stop_type)) {
-               status = BT_SELF_MESSAGE_ITERATOR_STATUS_END;
-       } else if (PyErr_GivenExceptionMatches(exc, py_mod_bt2_exc_try_again_type)) {
-               status = BT_SELF_MESSAGE_ITERATOR_STATUS_AGAIN;
-       } else {
-               bt2_py_loge_exception();
-               status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
+       BT_LOG_WRITE(log_level, BT_LOG_TAG, "%s", gstr->str);
+
+       if (append_error) {
+               restore_bt_error_and_append_current_exception_chain(
+                       self_component_class, self_component,
+                       self_message_iterator, module_name);
+
        }
 
 end:
-       PyErr_Clear();
-       return status;
+       if (gstr) {
+               g_string_free(gstr, TRUE);
+       }
+}
+
+static inline
+void loge_exception(const char *module_name)
+{
+       log_exception_and_maybe_append_error(BT_LOG_ERROR, true, NULL, NULL,
+               NULL, module_name);
 }
 
 static
-enum bt_query_status bt_py3_exc_to_query_status(void)
+void loge_exception_message_iterator(
+               bt_self_message_iterator *self_message_iterator)
 {
-       enum bt_query_status status = BT_QUERY_STATUS_OK;
+       log_exception_and_maybe_append_error(BT_LOG_ERROR, true, NULL, NULL,
+               self_message_iterator, NULL);
+}
+
+static inline
+void logw_exception(void)
+{
+       log_exception_and_maybe_append_error(BT_LOG_WARNING, false, NULL, NULL,
+               NULL, NULL);
+}
+
+static inline
+int py_exc_to_status(bt_self_component_class *self_component_class,
+               bt_self_component *self_component,
+               bt_self_message_iterator *self_message_iterator,
+               const char *module_name)
+{
+       int status = __BT_FUNC_STATUS_OK;
        PyObject *exc = PyErr_Occurred();
 
        if (!exc) {
@@ -251,17 +387,29 @@ enum bt_query_status bt_py3_exc_to_query_status(void)
        }
 
        if (PyErr_GivenExceptionMatches(exc,
-                       py_mod_bt2_exc_invalid_query_object_type)) {
-               status = BT_QUERY_STATUS_INVALID_OBJECT;
+                       py_mod_bt2_exc_try_again_type)) {
+               status = __BT_FUNC_STATUS_AGAIN;
        } else if (PyErr_GivenExceptionMatches(exc,
-                       py_mod_bt2_exc_invalid_query_params_type)) {
-               status = BT_QUERY_STATUS_INVALID_PARAMS;
+                       py_mod_bt2_exc_stop_type)) {
+               status = __BT_FUNC_STATUS_END;
        } else if (PyErr_GivenExceptionMatches(exc,
-                       py_mod_bt2_exc_try_again_type)) {
-               status = BT_QUERY_STATUS_AGAIN;
+                       py_mod_bt2_exc_invalid_object_type)) {
+               status = __BT_FUNC_STATUS_INVALID_OBJECT;
+       } else if (PyErr_GivenExceptionMatches(exc,
+                       py_mod_bt2_exc_invalid_params_type)) {
+               status = __BT_FUNC_STATUS_INVALID_PARAMS;
        } else {
-               bt2_py_loge_exception();
-               status = BT_QUERY_STATUS_ERROR;
+               /* Unknown exception: convert to general error */
+               log_exception_and_maybe_append_error(BT_LOG_WARNING, true,
+                       self_component_class, self_component,
+                       self_message_iterator, module_name);
+
+               if (PyErr_GivenExceptionMatches(exc,
+                               py_mod_bt2_exc_memory_error)) {
+                       status = __BT_FUNC_STATUS_MEMORY_ERROR;
+               } else {
+                       status = __BT_FUNC_STATUS_ERROR;
+               }
        }
 
 end:
@@ -270,7 +418,28 @@ end:
 }
 
 static
-bt_self_component_status bt_py3_component_class_init(
+int py_exc_to_status_component_class(bt_self_component_class *self_component_class)
+{
+       return py_exc_to_status(self_component_class, NULL, NULL, NULL);
+}
+
+static
+int py_exc_to_status_component(bt_self_component *self_component)
+{
+       return py_exc_to_status(NULL, self_component, NULL, NULL);
+}
+
+static
+int py_exc_to_status_message_iterator(
+               bt_self_message_iterator *self_message_iterator)
+{
+       return py_exc_to_status(NULL, NULL, self_message_iterator, NULL);
+}
+
+/* Component class proxy methods (delegate to the attached Python object) */
+
+static
+bt_component_class_init_method_status component_class_init(
                bt_self_component *self_component,
                void *self_component_v,
                swig_type_info *self_comp_cls_type_swig_type,
@@ -279,7 +448,7 @@ bt_self_component_status bt_py3_component_class_init(
 {
        const bt_component *component = bt_self_component_as_component(self_component);
        const bt_component_class *component_class = bt_component_borrow_class_const(component);
-       bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
+       bt_component_class_init_method_status status = __BT_FUNC_STATUS_OK;
        PyObject *py_cls = NULL;
        PyObject *py_comp = NULL;
        PyObject *py_params_ptr = NULL;
@@ -321,19 +490,18 @@ bt_self_component_status bt_py3_component_class_init(
        /*
         * Do the equivalent of this:
         *
-        *     py_comp = py_cls._init_from_native(py_comp_ptr, py_params_ptr)
+        *     py_comp = py_cls._bt_init_from_native(py_comp_ptr, py_params_ptr)
         *
-        * _UserComponentType._init_from_native() calls the Python
+        * _UserComponentType._bt_init_from_native() calls the Python
         * component object's __init__() function.
         */
        py_comp = PyObject_CallMethod(py_cls,
-               "_init_from_native", "(OO)", py_comp_ptr, py_params_ptr);
+               "_bt_init_from_native", "(OO)", py_comp_ptr, py_params_ptr);
        if (!py_comp) {
-               bt2_py_loge_exception();
-               BT_LOGE("Failed to call Python class's _init_from_native() method: "
+               BT_LOGW("Failed to call Python class's _bt_init_from_native() method: "
                        "py-cls-addr=%p", py_cls);
-
-               goto error;
+               status = py_exc_to_status_component(self_component);
+               goto end;
        }
 
        /*
@@ -346,7 +514,7 @@ bt_self_component_status bt_py3_component_class_init(
        goto end;
 
 error:
-       status = BT_SELF_COMPONENT_STATUS_ERROR;
+       status = __BT_FUNC_STATUS_ERROR;
 
        /*
         * Clear any exception: we're returning a bad status anyway. If
@@ -369,12 +537,12 @@ end:
  */
 
 static
-bt_self_component_status bt_py3_component_class_source_init(
+bt_component_class_init_method_status component_class_source_init(
                bt_self_component_source *self_component_source,
                const bt_value *params, void *init_method_data)
 {
        bt_self_component *self_component = bt_self_component_source_as_self_component(self_component_source);
-       return bt_py3_component_class_init(
+       return component_class_init(
                self_component,
                self_component_source,
                SWIGTYPE_p_bt_self_component_source,
@@ -382,12 +550,12 @@ bt_self_component_status bt_py3_component_class_source_init(
 }
 
 static
-bt_self_component_status bt_py3_component_class_filter_init(
+bt_component_class_init_method_status component_class_filter_init(
                bt_self_component_filter *self_component_filter,
                const bt_value *params, void *init_method_data)
 {
        bt_self_component *self_component = bt_self_component_filter_as_self_component(self_component_filter);
-       return bt_py3_component_class_init(
+       return component_class_init(
                self_component,
                self_component_filter,
                SWIGTYPE_p_bt_self_component_filter,
@@ -395,12 +563,12 @@ bt_self_component_status bt_py3_component_class_filter_init(
 }
 
 static
-bt_self_component_status bt_py3_component_class_sink_init(
+bt_component_class_init_method_status component_class_sink_init(
                bt_self_component_sink *self_component_sink,
                const bt_value *params, void *init_method_data)
 {
        bt_self_component *self_component = bt_self_component_sink_as_self_component(self_component_sink);
-       return bt_py3_component_class_init(
+       return component_class_init(
                self_component,
                self_component_sink,
                SWIGTYPE_p_bt_self_component_sink,
@@ -408,7 +576,7 @@ bt_self_component_status bt_py3_component_class_sink_init(
 }
 
 static
-void bt_py3_component_class_finalize(bt_self_component *self_component)
+void component_class_finalize(bt_self_component *self_component)
 {
        PyObject *py_comp = bt_self_component_get_data(self_component);
        BT_ASSERT(py_comp);
@@ -418,7 +586,8 @@ void bt_py3_component_class_finalize(bt_self_component *self_component)
                "_finalize", NULL);
 
        if (PyErr_Occurred()) {
-               BT_LOGW("User's _finalize() method raised an exception: ignoring.");
+               BT_LOGW("User component's _finalize() method raised an exception: ignoring:");
+               logw_exception();
        }
 
        /*
@@ -432,28 +601,28 @@ void bt_py3_component_class_finalize(bt_self_component *self_component)
 }
 
 static
-void bt_py3_component_class_source_finalize(bt_self_component_source *self_component_source)
+void component_class_source_finalize(bt_self_component_source *self_component_source)
 {
        bt_self_component *self_component = bt_self_component_source_as_self_component(self_component_source);
-       bt_py3_component_class_finalize(self_component);
+       component_class_finalize(self_component);
 }
 
 static
-void bt_py3_component_class_filter_finalize(bt_self_component_filter *self_component_filter)
+void component_class_filter_finalize(bt_self_component_filter *self_component_filter)
 {
        bt_self_component *self_component = bt_self_component_filter_as_self_component(self_component_filter);
-       bt_py3_component_class_finalize(self_component);
+       component_class_finalize(self_component);
 }
 
 static
-void bt_py3_component_class_sink_finalize(bt_self_component_sink *self_component_sink)
+void component_class_sink_finalize(bt_self_component_sink *self_component_sink)
 {
        bt_self_component *self_component = bt_self_component_sink_as_self_component(self_component_sink);
-       bt_py3_component_class_finalize(self_component);
+       component_class_finalize(self_component);
 }
 
 static
-bt_bool bt_py3_component_class_can_seek_beginning(
+bt_bool component_class_can_seek_beginning(
                bt_self_message_iterator *self_message_iterator)
 {
        PyObject *py_iter;
@@ -463,7 +632,7 @@ bt_bool bt_py3_component_class_can_seek_beginning(
        py_iter = bt_self_message_iterator_get_data(self_message_iterator);
        BT_ASSERT(py_iter);
 
-       py_result = PyObject_GetAttrString(py_iter, "_can_seek_beginning_from_native");
+       py_result = PyObject_GetAttrString(py_iter, "_bt_can_seek_beginning_from_native");
 
        BT_ASSERT(!py_result || PyBool_Check(py_result));
 
@@ -474,7 +643,7 @@ bt_bool bt_py3_component_class_can_seek_beginning(
                 * Once can_seek_beginning can report errors, convert the
                 * exception to a status.  For now, log and return false;
                 */
-               bt2_py_loge_exception();
+               loge_exception_message_iterator(self_message_iterator);
                PyErr_Clear();
        }
 
@@ -484,28 +653,25 @@ bt_bool bt_py3_component_class_can_seek_beginning(
 }
 
 static
-bt_self_message_iterator_status bt_py3_component_class_seek_beginning(
-               bt_self_message_iterator *self_message_iterator)
+bt_component_class_message_iterator_seek_beginning_method_status
+component_class_seek_beginning(bt_self_message_iterator *self_message_iterator)
 {
        PyObject *py_iter;
        PyObject *py_result;
-       bt_self_message_iterator_status status;
+       bt_component_class_message_iterator_seek_beginning_method_status status;
 
        py_iter = bt_self_message_iterator_get_data(self_message_iterator);
        BT_ASSERT(py_iter);
-
-       py_result = PyObject_CallMethod(py_iter, "_seek_beginning_from_native", NULL);
-
+       py_result = PyObject_CallMethod(py_iter, "_bt_seek_beginning_from_native",
+               NULL);
        BT_ASSERT(!py_result || py_result == Py_None);
-        status = bt_py3_exc_to_self_message_iterator_status();
-
+       status = py_exc_to_status_message_iterator(self_message_iterator);
        Py_XDECREF(py_result);
-
        return status;
 }
 
 static
-bt_self_component_status bt_py3_component_class_port_connected(
+bt_component_class_port_connected_method_status component_class_port_connected(
                bt_self_component *self_component,
                void *self_component_port,
                swig_type_info *self_component_port_swig_type,
@@ -513,7 +679,7 @@ bt_self_component_status bt_py3_component_class_port_connected(
                const void *other_port,
                swig_type_info *other_port_swig_type)
 {
-       bt_self_component_status status;
+       bt_component_class_port_connected_method_status status;
        PyObject *py_comp = NULL;
        PyObject *py_self_port_ptr = NULL;
        PyObject *py_other_port_ptr = NULL;
@@ -521,12 +687,11 @@ bt_self_component_status bt_py3_component_class_port_connected(
 
        py_comp = bt_self_component_get_data(self_component);
        BT_ASSERT(py_comp);
-
        py_self_port_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(self_component_port),
                self_component_port_swig_type, 0);
        if (!py_self_port_ptr) {
                BT_LOGF_STR("Failed to create a SWIG pointer object.");
-               status = BT_SELF_COMPONENT_STATUS_NOMEM;
+               status = __BT_FUNC_STATUS_MEMORY_ERROR;
                goto end;
        }
 
@@ -534,34 +699,32 @@ bt_self_component_status bt_py3_component_class_port_connected(
                other_port_swig_type, 0);
        if (!py_other_port_ptr) {
                BT_LOGF_STR("Failed to create a SWIG pointer object.");
-               status = BT_SELF_COMPONENT_STATUS_NOMEM;
+               status = __BT_FUNC_STATUS_MEMORY_ERROR;
                goto end;       }
 
        py_method_result = PyObject_CallMethod(py_comp,
-               "_port_connected_from_native", "(OiO)", py_self_port_ptr,
+               "_bt_port_connected_from_native", "(OiO)", py_self_port_ptr,
                self_component_port_type, py_other_port_ptr);
-
        BT_ASSERT(!py_method_result || py_method_result == Py_None);
-
-       status = bt_py3_exc_to_self_component_status();
+       status = py_exc_to_status_component(self_component);
 
 end:
        Py_XDECREF(py_self_port_ptr);
        Py_XDECREF(py_other_port_ptr);
        Py_XDECREF(py_method_result);
-
        return status;
 }
 
 static
-bt_self_component_status bt_py3_component_class_source_output_port_connected(
+bt_component_class_port_connected_method_status
+component_class_source_output_port_connected(
                bt_self_component_source *self_component_source,
                bt_self_component_port_output *self_component_port_output,
                const bt_port_input *other_port_input)
 {
        bt_self_component *self_component = bt_self_component_source_as_self_component(self_component_source);
 
-       return bt_py3_component_class_port_connected(
+       return component_class_port_connected(
                self_component,
                self_component_port_output,
                SWIGTYPE_p_bt_self_component_port_output,
@@ -571,14 +734,15 @@ bt_self_component_status bt_py3_component_class_source_output_port_connected(
 }
 
 static
-bt_self_component_status bt_py3_component_class_filter_input_port_connected(
+bt_component_class_port_connected_method_status
+component_class_filter_input_port_connected(
                bt_self_component_filter *self_component_filter,
                bt_self_component_port_input *self_component_port_input,
                const bt_port_output *other_port_output)
 {
        bt_self_component *self_component = bt_self_component_filter_as_self_component(self_component_filter);
 
-       return bt_py3_component_class_port_connected(
+       return component_class_port_connected(
                self_component,
                self_component_port_input,
                SWIGTYPE_p_bt_self_component_port_input,
@@ -588,14 +752,15 @@ bt_self_component_status bt_py3_component_class_filter_input_port_connected(
 }
 
 static
-bt_self_component_status bt_py3_component_class_filter_output_port_connected(
+bt_component_class_port_connected_method_status
+component_class_filter_output_port_connected(
                bt_self_component_filter *self_component_filter,
                bt_self_component_port_output *self_component_port_output,
                const bt_port_input *other_port_input)
 {
        bt_self_component *self_component = bt_self_component_filter_as_self_component(self_component_filter);
 
-       return bt_py3_component_class_port_connected(
+       return component_class_port_connected(
                self_component,
                self_component_port_output,
                SWIGTYPE_p_bt_self_component_port_output,
@@ -605,14 +770,15 @@ bt_self_component_status bt_py3_component_class_filter_output_port_connected(
 }
 
 static
-bt_self_component_status bt_py3_component_class_sink_input_port_connected(
+bt_component_class_port_connected_method_status
+component_class_sink_input_port_connected(
                bt_self_component_sink *self_component_sink,
                bt_self_component_port_input *self_component_port_input,
                const bt_port_output *other_port_output)
 {
        bt_self_component *self_component = bt_self_component_sink_as_self_component(self_component_sink);
 
-       return bt_py3_component_class_port_connected(
+       return component_class_port_connected(
                self_component,
                self_component_port_input,
                SWIGTYPE_p_bt_self_component_port_input,
@@ -622,30 +788,28 @@ bt_self_component_status bt_py3_component_class_sink_input_port_connected(
 }
 
 static
-bt_self_component_status bt_py3_component_class_sink_graph_is_configured(
+bt_component_class_sink_graph_is_configured_method_status
+component_class_sink_graph_is_configured(
                bt_self_component_sink *self_component_sink)
 {
        PyObject *py_comp = NULL;
        PyObject *py_method_result = NULL;
-       bt_self_component_status status = BT_SELF_COMPONENT_STATUS_OK;
+       bt_component_class_sink_graph_is_configured_method_status status = __BT_FUNC_STATUS_OK;
        bt_self_component *self_component = bt_self_component_sink_as_self_component(self_component_sink);
 
        py_comp = bt_self_component_get_data(self_component);
        py_method_result = PyObject_CallMethod(py_comp,
-               "_graph_is_configured_from_native", NULL);
-
+               "_bt_graph_is_configured_from_native", NULL);
        BT_ASSERT(!py_method_result || py_method_result == Py_None);
-
-       status = bt_py3_exc_to_self_component_status();
-
+       status = py_exc_to_status_component(self_component);
        Py_XDECREF(py_method_result);
-
        return status;
 }
 
 static
-bt_query_status bt_py3_component_class_query(
+bt_component_class_query_method_status component_class_query(
                const bt_component_class *component_class,
+               bt_self_component_class *self_component_class,
                const bt_query_executor *query_executor,
                const char *object, const bt_value *params,
                bt_logging_level log_level,
@@ -657,7 +821,7 @@ bt_query_status bt_py3_component_class_query(
        PyObject *py_query_func = NULL;
        PyObject *py_object = NULL;
        PyObject *py_results_addr = NULL;
-       bt_query_status status = BT_QUERY_STATUS_OK;
+       bt_component_class_query_method_status status = __BT_FUNC_STATUS_OK;
 
        py_cls = lookup_cc_ptr_to_py_cls(component_class);
        if (!py_cls) {
@@ -687,13 +851,12 @@ bt_query_status bt_py3_component_class_query(
        }
 
        py_results_addr = PyObject_CallMethod(py_cls,
-               "_query_from_native", "(OOOi)", py_query_exec_ptr,
+               "_bt_query_from_native", "(OOOi)", py_query_exec_ptr,
                py_object, py_params_ptr, (int) log_level);
-
        if (!py_results_addr) {
-               BT_LOGE("Failed to call Python class's _query_from_native() method: "
+               BT_LOGW("Failed to call Python class's _bt_query_from_native() method: "
                        "py-cls-addr=%p", py_cls);
-               status = bt_py3_exc_to_query_status();
+               status = py_exc_to_status_component_class(self_component_class);
                goto end;
        }
 
@@ -709,7 +872,7 @@ bt_query_status bt_py3_component_class_query(
 
 error:
        PyErr_Clear();
-       status = BT_QUERY_STATUS_ERROR;
+       status = __BT_FUNC_STATUS_ERROR;
 
 end:
        Py_XDECREF(py_params_ptr);
@@ -721,7 +884,7 @@ end:
 }
 
 static
-bt_query_status bt_py3_component_class_source_query(
+bt_component_class_query_method_status component_class_source_query(
                bt_self_component_class_source *self_component_class_source,
                const bt_query_executor *query_executor,
                const char *object, const bt_value *params,
@@ -730,11 +893,13 @@ bt_query_status bt_py3_component_class_source_query(
 {
        const bt_component_class_source *component_class_source = bt_self_component_class_source_as_component_class_source(self_component_class_source);
        const bt_component_class *component_class = bt_component_class_source_as_component_class_const(component_class_source);
-       return bt_py3_component_class_query(component_class, query_executor, object, params, log_level, result);
+       bt_self_component_class *self_component_class = bt_self_component_class_source_as_self_component_class(self_component_class_source);
+
+       return component_class_query(component_class, self_component_class, query_executor, object, params, log_level, result);
 }
 
 static
-bt_query_status bt_py3_component_class_filter_query(
+bt_component_class_query_method_status component_class_filter_query(
                bt_self_component_class_filter *self_component_class_filter,
                const bt_query_executor *query_executor,
                const char *object, const bt_value *params,
@@ -743,11 +908,13 @@ bt_query_status bt_py3_component_class_filter_query(
 {
        const bt_component_class_filter *component_class_filter = bt_self_component_class_filter_as_component_class_filter(self_component_class_filter);
        const bt_component_class *component_class = bt_component_class_filter_as_component_class_const(component_class_filter);
-       return bt_py3_component_class_query(component_class, query_executor, object, params, log_level, result);
+       bt_self_component_class *self_component_class = bt_self_component_class_filter_as_self_component_class(self_component_class_filter);
+
+       return component_class_query(component_class, self_component_class, query_executor, object, params, log_level, result);
 }
 
 static
-bt_query_status bt_py3_component_class_sink_query(
+bt_component_class_query_method_status component_class_sink_query(
                bt_self_component_class_sink *self_component_class_sink,
                const bt_query_executor *query_executor,
                const char *object, const bt_value *params,
@@ -756,16 +923,19 @@ bt_query_status bt_py3_component_class_sink_query(
 {
        const bt_component_class_sink *component_class_sink = bt_self_component_class_sink_as_component_class_sink(self_component_class_sink);
        const bt_component_class *component_class = bt_component_class_sink_as_component_class_const(component_class_sink);
-       return bt_py3_component_class_query(component_class, query_executor, object, params, log_level, result);
+       bt_self_component_class *self_component_class = bt_self_component_class_sink_as_self_component_class(self_component_class_sink);
+
+       return component_class_query(component_class, self_component_class, query_executor, object, params, log_level, result);
 }
 
 static
-bt_self_message_iterator_status bt_py3_component_class_message_iterator_init(
+bt_component_class_message_iterator_init_method_status
+component_class_message_iterator_init(
                bt_self_message_iterator *self_message_iterator,
                bt_self_component *self_component,
                bt_self_component_port_output *self_component_port_output)
 {
-       bt_self_message_iterator_status status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK;
+       bt_component_class_message_iterator_init_method_status status = __BT_FUNC_STATUS_OK;
        PyObject *py_comp_cls = NULL;
        PyObject *py_iter_cls = NULL;
        PyObject *py_iter_ptr = NULL;
@@ -780,19 +950,23 @@ bt_self_message_iterator_status bt_py3_component_class_message_iterator_init(
        py_comp_cls = PyObject_GetAttrString(py_comp, "__class__");
        if (!py_comp_cls) {
                BT_LOGE_STR("Cannot get Python object's `__class__` attribute.");
-               goto error;
+               goto python_error;
        }
 
        py_iter_cls = PyObject_GetAttrString(py_comp_cls, "_iter_cls");
        if (!py_iter_cls) {
                BT_LOGE_STR("Cannot get Python class's `_iter_cls` attribute.");
-               goto error;
+               goto python_error;
        }
 
        py_iter_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(self_message_iterator),
                SWIGTYPE_p_bt_self_message_iterator, 0);
        if (!py_iter_ptr) {
-               BT_LOGE_STR("Failed to create a SWIG pointer object.");
+               const char *err = "Failed to create a SWIG pointer object.";
+
+               BT_LOGE_STR(err);
+               BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_MESSAGE_ITERATOR(
+                       self_message_iterator, err);
                goto error;
        }
 
@@ -807,8 +981,7 @@ bt_self_message_iterator_status bt_py3_component_class_message_iterator_init(
        if (!py_iter) {
                BT_LOGE("Failed to call Python class's __new__() method: "
                        "py-cls-addr=%p", py_iter_cls);
-               bt2_py_loge_exception();
-               goto error;
+               goto python_error;
        }
 
        /*
@@ -816,25 +989,30 @@ bt_self_message_iterator_status bt_py3_component_class_message_iterator_init(
         *
         *     py_iter.__init__(self_output_port)
         *
-         * through the _init_for_native helper static method.
+        * through the _init_for_native helper static method.
         *
         * At this point, py_iter._ptr is set, so this initialization
         * function has access to self._component (which gives it the
         * user Python component object from which the iterator was
         * created).
         */
-        py_component_port_output_ptr = SWIG_NewPointerObj(SWIG_as_voidptr(self_component_port_output),
+       py_component_port_output_ptr = SWIG_NewPointerObj(
+               SWIG_as_voidptr(self_component_port_output),
                SWIGTYPE_p_bt_self_component_port_output, 0);
        if (!py_component_port_output_ptr) {
-               BT_LOGE_STR("Failed to create a SWIG pointer object.");
+               const char *err = "Failed to create a SWIG pointer object.";
+
+               BT_LOGE_STR(err);
+               BT_CURRENT_THREAD_ERROR_APPEND_CAUSE_FROM_MESSAGE_ITERATOR(
+                       self_message_iterator, err);
                goto error;
        }
 
-       py_init_method_result = PyObject_CallMethod(py_iter, "_init_from_native", "O", py_component_port_output_ptr);
+       py_init_method_result = PyObject_CallMethod(py_iter,
+               "_bt_init_from_native", "O", py_component_port_output_ptr);
        if (!py_init_method_result) {
-               BT_LOGE_STR("User's __init__() method failed.");
-               bt2_py_loge_exception();
-               goto error;
+               BT_LOGE_STR("User's __init__() method failed:");
+               goto python_error;
        }
 
        /*
@@ -859,24 +1037,19 @@ bt_self_message_iterator_status bt_py3_component_class_message_iterator_init(
        py_iter = NULL;
        goto end;
 
-error:
-       status = bt_py3_exc_to_self_message_iterator_status();
-       if (status == BT_SELF_MESSAGE_ITERATOR_STATUS_OK) {
-               /*
-                * Looks like there wasn't any exception from the Python
-                * side, but we're still in an error state here.
-                */
-               status = BT_SELF_MESSAGE_ITERATOR_STATUS_ERROR;
-       }
+python_error:
+       /* Handling of errors that cause a Python exception to be set. */
+       status = py_exc_to_status_message_iterator(self_message_iterator);
+       BT_ASSERT(status != __BT_FUNC_STATUS_OK);
+       goto end;
 
-       /*
-        * Clear any exception: we're returning a bad status anyway. If
-        * this call originated from Python, then the user gets an
-        * appropriate creation error.
-        */
-       PyErr_Clear();
+error:
+       /* Handling of errors that don't cause a Python exception to be set. */
+       status = __BT_FUNC_STATUS_ERROR;
 
 end:
+       BT_ASSERT(!PyErr_Occurred());
+
        Py_XDECREF(py_comp_cls);
        Py_XDECREF(py_iter_cls);
        Py_XDECREF(py_iter_ptr);
@@ -887,27 +1060,31 @@ end:
 }
 
 static
-bt_self_message_iterator_status bt_py3_component_class_source_message_iterator_init(
+bt_component_class_message_iterator_init_method_status
+component_class_source_message_iterator_init(
                bt_self_message_iterator *self_message_iterator,
                bt_self_component_source *self_component_source,
                bt_self_component_port_output *self_component_port_output)
 {
        bt_self_component *self_component = bt_self_component_source_as_self_component(self_component_source);
-       return bt_py3_component_class_message_iterator_init(self_message_iterator, self_component, self_component_port_output);
+
+       return component_class_message_iterator_init(self_message_iterator, self_component, self_component_port_output);
 }
 
 static
-bt_self_message_iterator_status bt_py3_component_class_filter_message_iterator_init(
+bt_component_class_message_iterator_init_method_status
+component_class_filter_message_iterator_init(
                bt_self_message_iterator *self_message_iterator,
                bt_self_component_filter *self_component_filter,
                bt_self_component_port_output *self_component_port_output)
 {
        bt_self_component *self_component = bt_self_component_filter_as_self_component(self_component_filter);
-       return bt_py3_component_class_message_iterator_init(self_message_iterator, self_component, self_component_port_output);
+
+       return component_class_message_iterator_init(self_message_iterator, self_component, self_component_port_output);
 }
 
 static
-void bt_py3_component_class_message_iterator_finalize(
+void component_class_message_iterator_finalize(
                bt_self_message_iterator *message_iterator)
 {
        PyObject *py_message_iter = bt_self_message_iterator_get_data(message_iterator);
@@ -920,7 +1097,8 @@ void bt_py3_component_class_message_iterator_finalize(
                "_finalize", NULL);
 
        if (PyErr_Occurred()) {
-               BT_LOGW("User's _finalize() method raised an exception: ignoring.");
+               BT_LOGW("User's _finalize() method raised an exception: ignoring:");
+               logw_exception();
        }
 
        /*
@@ -936,21 +1114,22 @@ void bt_py3_component_class_message_iterator_finalize(
 /* Valid for both sources and filters. */
 
 static
-bt_self_message_iterator_status bt_py3_component_class_message_iterator_next(
+bt_component_class_message_iterator_next_method_status
+component_class_message_iterator_next(
                bt_self_message_iterator *message_iterator,
                bt_message_array_const msgs, uint64_t capacity,
                uint64_t *count)
 {
-       bt_self_message_iterator_status status = BT_SELF_MESSAGE_ITERATOR_STATUS_OK;
+       bt_component_class_message_iterator_next_method_status status = __BT_FUNC_STATUS_OK;
        PyObject *py_message_iter = bt_self_message_iterator_get_data(message_iterator);
        PyObject *py_method_result = NULL;
 
        BT_ASSERT(py_message_iter);
        py_method_result = PyObject_CallMethod(py_message_iter,
-               "_next_from_native", NULL);
+               "_bt_next_from_native", NULL);
        if (!py_method_result) {
-               status = bt_py3_exc_to_self_message_iterator_status();
-               BT_ASSERT(status != BT_SELF_MESSAGE_ITERATOR_STATUS_OK);
+               status = py_exc_to_status_message_iterator(message_iterator);
+               BT_ASSERT(status != __BT_FUNC_STATUS_OK);
                goto end;
        }
 
@@ -972,24 +1151,23 @@ end:
 }
 
 static
-bt_self_component_status bt_py3_component_class_sink_consume(
-       bt_self_component_sink *self_component_sink)
+bt_component_class_sink_consume_method_status
+component_class_sink_consume(bt_self_component_sink *self_component_sink)
 {
        bt_self_component *self_component = bt_self_component_sink_as_self_component(self_component_sink);
        PyObject *py_comp = bt_self_component_get_data(self_component);
        PyObject *py_method_result = NULL;
-       bt_self_component_status status;
+       bt_component_class_sink_consume_method_status status;
 
        BT_ASSERT(py_comp);
        py_method_result = PyObject_CallMethod(py_comp,
                "_consume", NULL);
-
-       status = bt_py3_exc_to_self_component_status();
-       if (!py_method_result && status == BT_SELF_COMPONENT_STATUS_OK) {
+       status = py_exc_to_status_component(self_component);
+       if (!py_method_result && status == __BT_FUNC_STATUS_OK) {
                /* Pretty sure this should never happen, but just in case */
                BT_LOGE("User's _consume() method failed without raising an exception: "
                        "status=%d", status);
-               status = BT_SELF_COMPONENT_STATUS_ERROR;
+               status = __BT_FUNC_STATUS_ERROR;
        }
 
        Py_XDECREF(py_method_result);
@@ -997,7 +1175,7 @@ bt_self_component_status bt_py3_component_class_sink_consume(
 }
 
 static
-int bt_py3_component_class_set_help_and_desc(
+int component_class_set_help_and_desc(
                bt_component_class *component_class,
                const char *description, const char *help)
 {
@@ -1028,7 +1206,7 @@ end:
 }
 
 static
-bt_component_class_source *bt_py3_component_class_source_create(
+bt_component_class_source *bt_bt2_component_class_source_create(
                PyObject *py_cls, const char *name, const char *description,
                const char *help)
 {
@@ -1037,9 +1215,8 @@ bt_component_class_source *bt_py3_component_class_source_create(
        int ret;
 
        BT_ASSERT(py_cls);
-
        component_class_source = bt_component_class_source_create(name,
-               bt_py3_component_class_message_iterator_next);
+               component_class_message_iterator_next);
        if (!component_class_source) {
                BT_LOGE_STR("Cannot create source component class.");
                goto end;
@@ -1047,32 +1224,31 @@ bt_component_class_source *bt_py3_component_class_source_create(
 
        component_class = bt_component_class_source_as_component_class(component_class_source);
 
-       if (bt_py3_component_class_set_help_and_desc(component_class, description, help)) {
+       if (component_class_set_help_and_desc(component_class, description, help)) {
                goto end;
        }
 
-       ret = bt_component_class_source_set_init_method(component_class_source, bt_py3_component_class_source_init);
+       ret = bt_component_class_source_set_init_method(component_class_source, component_class_source_init);
        BT_ASSERT(ret == 0);
-       ret = bt_component_class_source_set_finalize_method(component_class_source, bt_py3_component_class_source_finalize);
+       ret = bt_component_class_source_set_finalize_method(component_class_source, component_class_source_finalize);
        BT_ASSERT(ret == 0);
        ret = bt_component_class_source_set_message_iterator_can_seek_beginning_method(component_class_source,
-               bt_py3_component_class_can_seek_beginning);
+               component_class_can_seek_beginning);
        BT_ASSERT(ret == 0);
        ret = bt_component_class_source_set_message_iterator_seek_beginning_method(component_class_source,
-               bt_py3_component_class_seek_beginning);
+               component_class_seek_beginning);
        BT_ASSERT(ret == 0);
        ret = bt_component_class_source_set_output_port_connected_method(component_class_source,
-               bt_py3_component_class_source_output_port_connected);
+               component_class_source_output_port_connected);
        BT_ASSERT(ret == 0);
-       ret = bt_component_class_source_set_query_method(component_class_source, bt_py3_component_class_source_query);
+       ret = bt_component_class_source_set_query_method(component_class_source, component_class_source_query);
        BT_ASSERT(ret == 0);
        ret = bt_component_class_source_set_message_iterator_init_method(
-               component_class_source, bt_py3_component_class_source_message_iterator_init);
+               component_class_source, component_class_source_message_iterator_init);
        BT_ASSERT(ret == 0);
        ret = bt_component_class_source_set_message_iterator_finalize_method(
-               component_class_source, bt_py3_component_class_message_iterator_finalize);
+               component_class_source, component_class_message_iterator_finalize);
        BT_ASSERT(ret == 0);
-
        register_cc_ptr_to_py_cls(component_class, py_cls);
 
 end:
@@ -1080,7 +1256,7 @@ end:
 }
 
 static
-bt_component_class_filter *bt_py3_component_class_filter_create(
+bt_component_class_filter *bt_bt2_component_class_filter_create(
                PyObject *py_cls, const char *name, const char *description,
                const char *help)
 {
@@ -1089,9 +1265,8 @@ bt_component_class_filter *bt_py3_component_class_filter_create(
        int ret;
 
        BT_ASSERT(py_cls);
-
        component_class_filter = bt_component_class_filter_create(name,
-               bt_py3_component_class_message_iterator_next);
+               component_class_message_iterator_next);
        if (!component_class_filter) {
                BT_LOGE_STR("Cannot create filter component class.");
                goto end;
@@ -1099,35 +1274,34 @@ bt_component_class_filter *bt_py3_component_class_filter_create(
 
        component_class = bt_component_class_filter_as_component_class(component_class_filter);
 
-       if (bt_py3_component_class_set_help_and_desc(component_class, description, help)) {
+       if (component_class_set_help_and_desc(component_class, description, help)) {
                goto end;
        }
 
-       ret = bt_component_class_filter_set_init_method(component_class_filter, bt_py3_component_class_filter_init);
+       ret = bt_component_class_filter_set_init_method(component_class_filter, component_class_filter_init);
        BT_ASSERT(ret == 0);
-       ret = bt_component_class_filter_set_finalize_method (component_class_filter, bt_py3_component_class_filter_finalize);
+       ret = bt_component_class_filter_set_finalize_method (component_class_filter, component_class_filter_finalize);
        BT_ASSERT(ret == 0);
        ret = bt_component_class_filter_set_message_iterator_can_seek_beginning_method(component_class_filter,
-               bt_py3_component_class_can_seek_beginning);
+               component_class_can_seek_beginning);
        BT_ASSERT(ret == 0);
        ret = bt_component_class_filter_set_message_iterator_seek_beginning_method(component_class_filter,
-               bt_py3_component_class_seek_beginning);
+               component_class_seek_beginning);
        BT_ASSERT(ret == 0);
        ret = bt_component_class_filter_set_input_port_connected_method(component_class_filter,
-               bt_py3_component_class_filter_input_port_connected);
+               component_class_filter_input_port_connected);
        BT_ASSERT(ret == 0);
        ret = bt_component_class_filter_set_output_port_connected_method(component_class_filter,
-               bt_py3_component_class_filter_output_port_connected);
+               component_class_filter_output_port_connected);
        BT_ASSERT(ret == 0);
-       ret = bt_component_class_filter_set_query_method(component_class_filter, bt_py3_component_class_filter_query);
+       ret = bt_component_class_filter_set_query_method(component_class_filter, component_class_filter_query);
        BT_ASSERT(ret == 0);
        ret = bt_component_class_filter_set_message_iterator_init_method(
-               component_class_filter, bt_py3_component_class_filter_message_iterator_init);
+               component_class_filter, component_class_filter_message_iterator_init);
        BT_ASSERT(ret == 0);
        ret = bt_component_class_filter_set_message_iterator_finalize_method(
-               component_class_filter, bt_py3_component_class_message_iterator_finalize);
+               component_class_filter, component_class_message_iterator_finalize);
        BT_ASSERT(ret == 0);
-
        register_cc_ptr_to_py_cls(component_class, py_cls);
 
 end:
@@ -1135,7 +1309,7 @@ end:
 }
 
 static
-bt_component_class_sink *bt_py3_component_class_sink_create(
+bt_component_class_sink *bt_bt2_component_class_sink_create(
                PyObject *py_cls, const char *name, const char *description,
                const char *help)
 {
@@ -1144,8 +1318,7 @@ bt_component_class_sink *bt_py3_component_class_sink_create(
        int ret;
 
        BT_ASSERT(py_cls);
-
-       component_class_sink = bt_component_class_sink_create(name, bt_py3_component_class_sink_consume);
+       component_class_sink = bt_component_class_sink_create(name, component_class_sink_consume);
 
        if (!component_class_sink) {
                BT_LOGE_STR("Cannot create sink component class.");
@@ -1154,23 +1327,22 @@ bt_component_class_sink *bt_py3_component_class_sink_create(
 
        component_class = bt_component_class_sink_as_component_class(component_class_sink);
 
-       if (bt_py3_component_class_set_help_and_desc(component_class, description, help)) {
+       if (component_class_set_help_and_desc(component_class, description, help)) {
                goto end;
        }
 
-       ret = bt_component_class_sink_set_init_method(component_class_sink, bt_py3_component_class_sink_init);
+       ret = bt_component_class_sink_set_init_method(component_class_sink, component_class_sink_init);
        BT_ASSERT(ret == 0);
-       ret = bt_component_class_sink_set_finalize_method(component_class_sink, bt_py3_component_class_sink_finalize);
+       ret = bt_component_class_sink_set_finalize_method(component_class_sink, component_class_sink_finalize);
        BT_ASSERT(ret == 0);
        ret = bt_component_class_sink_set_input_port_connected_method(component_class_sink,
-               bt_py3_component_class_sink_input_port_connected);
+               component_class_sink_input_port_connected);
        BT_ASSERT(ret == 0);
        ret = bt_component_class_sink_set_graph_is_configured_method(component_class_sink,
-               bt_py3_component_class_sink_graph_is_configured);
+               component_class_sink_graph_is_configured);
        BT_ASSERT(ret == 0);
-       ret = bt_component_class_sink_set_query_method(component_class_sink, bt_py3_component_class_sink_query);
+       ret = bt_component_class_sink_set_query_method(component_class_sink, component_class_sink_query);
        BT_ASSERT(ret == 0);
-
        register_cc_ptr_to_py_cls(component_class, py_cls);
 
 end:
@@ -1178,14 +1350,14 @@ end:
 }
 %}
 
-struct bt_component_class_source *bt_py3_component_class_source_create(
+struct bt_component_class_source *bt_bt2_component_class_source_create(
                PyObject *py_cls, const char *name, const char *description,
                const char *help);
-struct bt_component_class_filter *bt_py3_component_class_filter_create(
+struct bt_component_class_filter *bt_bt2_component_class_filter_create(
                PyObject *py_cls, const char *name, const char *description,
                const char *help);
-struct bt_component_class_sink *bt_py3_component_class_sink_create(
+struct bt_component_class_sink *bt_bt2_component_class_sink_create(
                PyObject *py_cls, const char *name, const char *description,
                const char *help);
-void bt_py3_cc_init_from_bt2(void);
-void bt_py3_cc_exit_handler(void);
+void bt_bt2_cc_init_from_bt2(void);
+void bt_bt2_cc_exit_handler(void);
This page took 0.043001 seconds and 4 git commands to generate.