aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2021-05-16 12:24:00 +0200
committerChristian Tismer <tismer@stackless.com>2023-03-10 18:40:10 +0100
commit665d01d76fdd5d511255be171f92a6c51a8b53a7 (patch)
tree8c56e19aa18de2e997d0b4a38b8554b8971d4986
parentcbb0b363ea272b452654b3dd918718e749448a2b (diff)
Shiboken: Improve an error message by giving more context
"You can't initialize an object twice" was augmented by giving class info. "You can't initialize an PySide6.QtWidgets.QLabel object in class F twice!" Task-number: PYSIDE-1564 Change-Id: Ie243b884caae47f05ec1138cc1c7063b0b477b56 Pick-to: 6.4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--sources/shiboken6/libshiboken/basewrapper.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/sources/shiboken6/libshiboken/basewrapper.cpp b/sources/shiboken6/libshiboken/basewrapper.cpp
index 56873b197..3dd5d3539 100644
--- a/sources/shiboken6/libshiboken/basewrapper.cpp
+++ b/sources/shiboken6/libshiboken/basewrapper.cpp
@@ -1248,7 +1248,8 @@ bool setCppPointer(SbkObject *sbkObj, PyTypeObject *desiredType, void *cptr)
const bool alreadyInitialized = sbkObj->d->cptr[idx] != nullptr;
if (alreadyInitialized)
- PyErr_SetString(PyExc_RuntimeError, "You can't initialize an object twice!");
+ PyErr_Format(PyExc_RuntimeError, "You can't initialize an %s object in class %s twice!",
+ desiredType->tp_name, type->tp_name);
else
sbkObj->d->cptr[idx] = cptr;