aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <[email protected]>2025-05-14 10:09:38 +0200
committerFriedemann Kleint <[email protected]>2025-05-16 15:03:35 +0200
commit760abafd4906d995ec5e149c5c0c88dbe571f90b (patch)
treec9c5ab35bf22ab1eabdfc3968978ba0e661d94ae
parent28c0061af6b17219ba2bda3a217b76b044e80bcd (diff)
libshiboken6: Add warnings for conversion errors
Add warnings for: - Copy conversion Python to C++ is requested, but no copy conversion functions are registered. - Pointer conversion of non-SbkObject was requested, which falls back to pass through. Task-number: PYSIDE-2193 Change-Id: Id5c9d82c981bc63156187593da3593237186adba Reviewed-by: Shyamnath Premnadh <[email protected]>
-rw-r--r--sources/shiboken6/libshiboken/sbkconverter.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/sources/shiboken6/libshiboken/sbkconverter.cpp b/sources/shiboken6/libshiboken/sbkconverter.cpp
index 94bb1e2b4..1f79402b7 100644
--- a/sources/shiboken6/libshiboken/sbkconverter.cpp
+++ b/sources/shiboken6/libshiboken/sbkconverter.cpp
@@ -451,8 +451,11 @@ void nonePythonToCppNullPtr(PyObject *, void *cppOut)
void *cppPointer(PyTypeObject *desiredType, SbkObject *pyIn)
{
assert(pyIn);
- if (!ObjectType::checkType(desiredType))
+ if (!ObjectType::checkType(desiredType)) {
+ std::cerr << __FUNCTION__ << ": Conversion to non SbkObject type " << desiredType->tp_name
+ << " requested, falling back to pass-through.\n";
return pyIn;
+ }
auto *inType = Py_TYPE(pyIn);
if (ObjectType::hasCast(inType))
return ObjectType::cast(inType, pyIn, desiredType);
@@ -485,8 +488,14 @@ static void _pythonToCppCopy(const SbkConverter *converter, PyObject *pyIn, void
assert(pyIn);
assert(cppOut);
PythonToCppFunc toCpp = IsPythonToCppConvertible(converter, pyIn);
- if (toCpp)
+ if (toCpp) {
toCpp(pyIn, cppOut);
+ } else {
+ std::cerr << __FUNCTION__ << ": Cannot copy-convert " << pyIn;
+ if (pyIn)
+ std::cerr << " (" << Py_TYPE(pyIn)->tp_name << ')';
+ std::cerr << " to C++.\n";
+ }
}
void pythonToCppCopy(PyTypeObject *type, PyObject *pyIn, void *cppOut)