aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-12-05 10:06:06 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-12-10 10:06:51 +0100
commit8666fa17248fedee262c0d08d6edc12e8c537769 (patch)
tree4034fade3d1873235efe943460dac0b416ac2718 /sources/shiboken2
parent870b7f4c849ebbc5f39f1f2398e39a3b7dfd9562 (diff)
libshiboken/introduceWrapperType(): Emit warning on failures
Emit a warning when PyModule_AddObject(), SbkSpecial_Type_Ready() fail, which can happen when passing the wrong parent. Task-number: PYSIDE-454 Change-Id: I0c2da7292dc0a354c58a21bf4a1df9d350d15ab6 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2')
-rw-r--r--sources/shiboken2/libshiboken/basewrapper.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp
index dd5dc43e9..c4b640900 100644
--- a/sources/shiboken2/libshiboken/basewrapper.cpp
+++ b/sources/shiboken2/libshiboken/basewrapper.cpp
@@ -58,6 +58,8 @@
#include "qapp_macro.h"
#include "voidptr.h"
+#include <iostream>
+
#if defined(__APPLE__)
#include <dlfcn.h>
#endif
@@ -917,8 +919,11 @@ introduceWrapperType(PyObject *enclosingObject,
}
}
// PYSIDE-510: Here is the single change to support signatures.
- if (SbkSpecial_Type_Ready(enclosingObject, reinterpret_cast<PyTypeObject *>(type), signatureStrings) < 0)
+ if (SbkSpecial_Type_Ready(enclosingObject, reinterpret_cast<PyTypeObject *>(type), signatureStrings) < 0) {
+ std::cerr << "Warning: " << __FUNCTION__ << " returns nullptr for "
+ << typeName << '/' << originalName << " due to SbkSpecial_Type_Ready() failing\n";
return nullptr;
+ }
initPrivateData(type);
auto sotp = PepType_SOTP(type);
@@ -934,7 +939,13 @@ introduceWrapperType(PyObject *enclosingObject,
// PyModule_AddObject steals type's reference.
Py_INCREF(ob_type);
- return PyModule_AddObject(enclosingObject, typeName, ob_type) == 0 ? type : nullptr;
+ if (PyModule_AddObject(enclosingObject, typeName, ob_type) != 0) {
+ std::cerr << "Warning: " << __FUNCTION__ << " returns nullptr for "
+ << typeName << '/' << originalName << " due to PyModule_AddObject(enclosingObject="
+ << enclosingObject << ",ob_type=" << ob_type << ") failing\n";
+ return nullptr;
+ }
+ return type;
}
void setSubTypeInitHook(SbkObjectType *type, SubTypeInitHook func)