aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/libpysideremoteobjects/pysiderephandler.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2025-04-17 14:49:57 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2025-05-07 21:10:45 +0200
commitd8ca812879ad70cd2aa914ea76cd529786deadc6 (patch)
tree97140467bca8c9bcda6f492ecb8598c9db136179 /sources/pyside6/libpysideremoteobjects/pysiderephandler.cpp
parentcffe2bc71d8e5d88efb879e6fe68c730e547fc4d (diff)
libshiboken: Add utility class for stashing Python errors
It encapsulates fetching/restoring errors and uses the old or new exception API depending on version. Task-number: PYSIDE-3067 Change-Id: I6e39d92c7e79fed864b364a90c5bd5b474a41ed6 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside6/libpysideremoteobjects/pysiderephandler.cpp')
-rw-r--r--sources/pyside6/libpysideremoteobjects/pysiderephandler.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/sources/pyside6/libpysideremoteobjects/pysiderephandler.cpp b/sources/pyside6/libpysideremoteobjects/pysiderephandler.cpp
index bfe085456..aa59c329f 100644
--- a/sources/pyside6/libpysideremoteobjects/pysiderephandler.cpp
+++ b/sources/pyside6/libpysideremoteobjects/pysiderephandler.cpp
@@ -7,6 +7,7 @@
#include "pysidedynamiccommon_p.h"
#include <pep384ext.h>
+#include <sbkerrors.h>
#include <sbkstring.h>
#include <sbktypefactory.h>
#include <signature.h>
@@ -372,17 +373,11 @@ bool instantiateFromDefaultValue(QVariant &variant, const QString &defaultValue)
PyObject *pyResult = PyRun_String(code.c_str(), Py_eval_input, pyLocals, pyLocals);
if (!pyResult) {
- PyObject *ptype = nullptr;
- PyObject *pvalue = nullptr;
- PyObject *ptraceback = nullptr;
- PyErr_Fetch(&ptype, &pvalue, &ptraceback);
- PyErr_NormalizeException(&ptype, &pvalue, &ptraceback);
+ Shiboken::Errors::Stash errorStash;
PyErr_Format(PyExc_TypeError,
"Failed to generate default value. Error: %s. Problematic code: %s",
- Shiboken::String::toCString(PyObject_Str(pvalue)), code.c_str());
- Py_XDECREF(ptype);
- Py_XDECREF(pvalue);
- Py_XDECREF(ptraceback);
+ Shiboken::String::toCString(PyObject_Str(errorStash.getException())), code.c_str());
+ errorStash.release();
Py_DECREF(pyLocals);
return false;
}