diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-11-25 11:42:46 +0100 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2025-11-25 17:03:44 +0100 |
| commit | 4923cd128e9d3ff4e8279dae1382ff000c99bfa5 (patch) | |
| tree | 01012ed1b68ba48a7b8fc9c9df7c369e365d29a0 | |
| parent | 9086240ff5766b996fd5dd0020698932d38da039 (diff) | |
libshiboken: Remove PepErr_GetRaisedException()
The function was wrongly implemented, it is actually
meant to clear the error state and be used along
with PyErr_SetRaisedException() to replace the deprecated
PyErr_Fetch()/Restore(). It cannot really be implemented
in terms of PyErr_Fetch()/Restore().
Partially reverts 9aabb3a509594f59306a96679938f2f43a9830e6.
Task-number: PYSIDE-2747
Change-Id: I5ee57112c905e9112b758e27904bbf4fa768aeea
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
| -rw-r--r-- | sources/pyside6/plugins/designer/designercustomwidgets.cpp | 2 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/basewrapper.cpp | 6 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/pep384impl.cpp | 12 | ||||
| -rw-r--r-- | sources/shiboken6/libshiboken/pep384impl.h | 2 |
4 files changed, 4 insertions, 18 deletions
diff --git a/sources/pyside6/plugins/designer/designercustomwidgets.cpp b/sources/pyside6/plugins/designer/designercustomwidgets.cpp index d13539859..c43af1f6d 100644 --- a/sources/pyside6/plugins/designer/designercustomwidgets.cpp +++ b/sources/pyside6/plugins/designer/designercustomwidgets.cpp @@ -68,7 +68,7 @@ static QString pyErrorMessage() #else // <3.11 if (PyObject *pvalue = PyErr_GetRaisedException()) { result = pyStr(pvalue); - Py_DECREF(pvalue); + PyErr_SetRaisedException(pvalue); } #endif return result; diff --git a/sources/shiboken6/libshiboken/basewrapper.cpp b/sources/shiboken6/libshiboken/basewrapper.cpp index 4b69abd4d..1bcc27218 100644 --- a/sources/shiboken6/libshiboken/basewrapper.cpp +++ b/sources/shiboken6/libshiboken/basewrapper.cpp @@ -869,10 +869,10 @@ static std::string msgFailedToInitializeType(const char *description) { std::ostringstream stream; stream << "libshiboken: Failed to initialize " << description; - if (auto *error = PepErr_GetRaisedException()) { - if (auto *str = PyObject_Str(error)) + if (PyErr_Occurred() != nullptr) { + Shiboken::Errors::Stash stash; + if (auto *str = PyObject_Str(stash.getException())) stream << ": " << Shiboken::String::toCString(str); - Py_DECREF(error); } stream << '.'; return stream.str(); diff --git a/sources/shiboken6/libshiboken/pep384impl.cpp b/sources/shiboken6/libshiboken/pep384impl.cpp index 4afdcdc8b..e274b4a62 100644 --- a/sources/shiboken6/libshiboken/pep384impl.cpp +++ b/sources/shiboken6/libshiboken/pep384impl.cpp @@ -391,18 +391,6 @@ Pep_GetVerboseFlag() // Support for pyerrors.h #ifdef PEP_OLD_ERR_API -// Emulate PyErr_GetRaisedException() using the deprecated PyErr_Fetch()/PyErr_Store() -PyObject *PepErr_GetRaisedException() -{ - PyObject *type{}; - PyObject *value{}; - PyObject *traceback{}; - PyErr_Fetch(&type, &value, &traceback); - Py_XINCREF(value); - PyErr_Restore(type, value, traceback); - return value; -} - struct PepException_HEAD { PyObject_HEAD diff --git a/sources/shiboken6/libshiboken/pep384impl.h b/sources/shiboken6/libshiboken/pep384impl.h index 0e32ec0c8..8552a1e40 100644 --- a/sources/shiboken6/libshiboken/pep384impl.h +++ b/sources/shiboken6/libshiboken/pep384impl.h @@ -192,11 +192,9 @@ LIBSHIBOKEN_API int Pep_GetVerboseFlag(void); // pyerrors.h #ifdef PEP_OLD_ERR_API -LIBSHIBOKEN_API PyObject *PepErr_GetRaisedException(); LIBSHIBOKEN_API PyObject *PepException_GetArgs(PyObject *ex); LIBSHIBOKEN_API void PepException_SetArgs(PyObject *ex, PyObject *args); #else -inline PyObject *PepErr_GetRaisedException() { return PyErr_GetRaisedException(); } inline PyObject *PepException_GetArgs(PyObject *ex) { return PyException_GetArgs(ex); } inline void PepException_SetArgs(PyObject *ex, PyObject *args) { PyException_SetArgs(ex, args); } |
