+ /*
+ * 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);
+
+ gstr = bt_py_common_format_exception(py_exc_type, py_exc_value,
+ py_exc_tb, BT_LOG_OUTPUT_LEVEL, false);