X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=src%2Fbindings%2Fpython%2Fbt2%2Fbt2%2Fnative_bt_component_class.i;h=ed939937e6cade034a4665ff1b2c0adb82f45460;hb=2c1d3e9111d8f1b55361b9b880350c2680c90093;hp=b9e91a4af86e83c9864bb89b8fc1998865aeb909;hpb=ce4923b0c7a2de36eba95725334d251e9aa08aad;p=babeltrace.git diff --git a/src/bindings/python/bt2/bt2/native_bt_component_class.i b/src/bindings/python/bt2/bt2/native_bt_component_class.i index b9e91a4a..ed939937 100644 --- a/src/bindings/python/bt2/bt2/native_bt_component_class.i +++ b/src/bindings/python/bt2/bt2/native_bt_component_class.i @@ -94,12 +94,12 @@ 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_object_type = NULL; static PyObject *py_mod_bt2_exc_invalid_params_type = NULL; -static PyObject *py_mod_bt2_exc_unsupported_type = NULL; static void bt_bt2_cc_init_from_bt2(void) @@ -115,8 +115,11 @@ void bt_bt2_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); @@ -129,9 +132,6 @@ void bt_bt2_cc_init_from_bt2(void) py_mod_bt2_exc_invalid_params_type = PyObject_GetAttrString(py_mod_bt2, "InvalidParams"); BT_ASSERT(py_mod_bt2_exc_invalid_params_type); - py_mod_bt2_exc_unsupported_type = - PyObject_GetAttrString(py_mod_bt2, "Unsupported"); - BT_ASSERT(py_mod_bt2_exc_unsupported_type); } static @@ -194,7 +194,7 @@ void restore_current_thread_error_and_append_exception_chain_recursive( } /* - * If the raised exception is a bt2.Error, restore the wrapped error. + * 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; @@ -202,7 +202,7 @@ void restore_current_thread_error_and_append_exception_chain_recursive( int ret; /* - * We never raise a bt2.Error with a cause: it should be the + * We never raise a bt2._Error with a cause: it should be the * end of the chain. */ BT_ASSERT(!py_exc_cause_value); @@ -266,21 +266,21 @@ end: * try: * try: * something_that_raises_bt2_error() - * except bt2.Error as e1: + * 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 + * 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 + * 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 + * 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 @@ -400,15 +400,18 @@ int py_exc_to_status(bt_self_component_class *self_component_class, } else if (PyErr_GivenExceptionMatches(exc, py_mod_bt2_exc_invalid_params_type)) { status = __BT_FUNC_STATUS_INVALID_PARAMS; - } else if (PyErr_GivenExceptionMatches(exc, - py_mod_bt2_exc_unsupported_type)) { - status = __BT_FUNC_STATUS_UNSUPPORTED; } else { /* 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); - status = __BT_FUNC_STATUS_ERROR; + + if (PyErr_GivenExceptionMatches(exc, + py_mod_bt2_exc_memory_error)) { + status = __BT_FUNC_STATUS_MEMORY_ERROR; + } else { + status = __BT_FUNC_STATUS_ERROR; + } } end: