From b34b7216550df2b4aae488753df2887f9dbe938d Mon Sep 17 00:00:00 2001 From: Malte Gotz Date: Tue, 3 Mar 2026 13:25:47 +0100 Subject: [PATCH 1/2] Fix bug, duplicating each entry if a list of bools is returned: PyBool is implemented as a subclass of int, thus bools were added twice to the val. Once from PyLong_Check and once from PyBool_Check. Treating bools separately is unnecessary because they are treated fine as long. --- src/pywrapper.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/pywrapper.cpp b/src/pywrapper.cpp index 2af3d65..2f251a2 100644 --- a/src/pywrapper.cpp +++ b/src/pywrapper.cpp @@ -302,11 +302,6 @@ bool PyWrapper::convert(void* in_, Variant& out) vl.push_back(val); t = Variant::Type::VECTOR_LONG; } - if (PyBool_Check(el) && (t == Variant::Type::NONE || t == Variant::Type::VECTOR_LONG)) { - long val = (PyObject_IsTrue(el) ? 1 : 0); - vl.push_back(val); - t = Variant::Type::VECTOR_LONG; - } if (PyFloat_Check(el) && (t == Variant::Type::NONE || t == Variant::Type::VECTOR_DOUBLE)) { double val = PyFloat_AsDouble(el); if (val == -1.0 && PyErr_Occurred()) { From c8c9674f9c757e8465604a6d7ed10c402a06ae3a Mon Sep 17 00:00:00 2001 From: Malte Gotz Date: Wed, 4 Mar 2026 09:34:04 +0100 Subject: [PATCH 2/2] Made type checks and conversions for list elements mutually exclusive. --- src/pywrapper.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pywrapper.cpp b/src/pywrapper.cpp index 2f251a2..4092495 100644 --- a/src/pywrapper.cpp +++ b/src/pywrapper.cpp @@ -291,6 +291,7 @@ bool PyWrapper::convert(void* in_, Variant& out) } vl.push_back(val); t = Variant::Type::VECTOR_LONG; + continue; } #endif if (PyLong_Check(el) && (t == Variant::Type::NONE || t == Variant::Type::VECTOR_LONG)) { @@ -301,6 +302,7 @@ bool PyWrapper::convert(void* in_, Variant& out) } vl.push_back(val); t = Variant::Type::VECTOR_LONG; + continue; } if (PyFloat_Check(el) && (t == Variant::Type::NONE || t == Variant::Type::VECTOR_DOUBLE)) { double val = PyFloat_AsDouble(el); @@ -310,10 +312,12 @@ bool PyWrapper::convert(void* in_, Variant& out) } vd.push_back(val); t = Variant::Type::VECTOR_DOUBLE; + continue; } #if PY_MAJOR_VERSION < 3 if (PyString_Check(el) && (t == Variant::Type::NONE || t == Variant::Type::VECTOR_STRING)) { const char *cval = PyString_AsString(el); + continue; #else if (PyUnicode_Check(el) && (t == Variant::Type::NONE || t == Variant::Type::VECTOR_STRING)) { const char *cval = PyBytes_AsString(PyUnicode_AsASCIIString(el)); @@ -324,6 +328,7 @@ bool PyWrapper::convert(void* in_, Variant& out) } vs.push_back(cval); t = Variant::Type::VECTOR_STRING; + continue; } }