aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/libshiboken/signature.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2/libshiboken/signature.cpp')
-rw-r--r--sources/shiboken2/libshiboken/signature.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/sources/shiboken2/libshiboken/signature.cpp b/sources/shiboken2/libshiboken/signature.cpp
index 564e5fcef..a8874e2e0 100644
--- a/sources/shiboken2/libshiboken/signature.cpp
+++ b/sources/shiboken2/libshiboken/signature.cpp
@@ -74,6 +74,7 @@ typedef struct safe_globals_struc {
// init part 2: run module
PyObject *sigparse_func;
PyObject *createsig_func;
+ PyObject *seterror_argument_func;
} safe_globals_struc, *safe_globals;
static safe_globals pyside_globals = 0;
@@ -510,6 +511,9 @@ init_phase_2(safe_globals_struc *p, PyMethodDef *methods)
p->createsig_func = PyObject_GetAttrString(p->helper_module, "create_signature");
if (p->createsig_func == NULL)
goto error;
+ p->seterror_argument_func = PyObject_GetAttrString(p->helper_module, "seterror_argument");
+ if (p->seterror_argument_func == NULL)
+ goto error;
return 0;
error:
@@ -950,4 +954,29 @@ FinishSignatureInitialization(PyObject *module, const char *signatures)
}
}
+void
+SetError_Argument(PyObject *args, const char *func_name)
+{
+ /*
+ * This function replaces the type error construction with extra
+ * overloads parameter in favor of using the signature module.
+ * Error messages are rare, so we do it completely in Python.
+ */
+ init_module_1();
+ init_module_2();
+ Shiboken::AutoDecRef res(PyObject_CallFunction(
+ pyside_globals->seterror_argument_func,
+ const_cast<char *>("(Os)"), args, func_name));
+ if (res.isNull()) {
+ PyErr_Print();
+ Py_FatalError("seterror_argument did not receive a result");
+ }
+ PyObject *err, *msg;
+ if (!PyArg_UnpackTuple(res, func_name, 2, 2, &err, &msg)) {
+ PyErr_Print();
+ Py_FatalError("unexpected failure in seterror_argument");
+ }
+ PyErr_SetObject(err, msg);
+}
+
} //extern "C"