aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2023-10-30 10:36:26 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-10-30 11:49:42 +0000
commitbf7534e2fab3f35be38dff3153f58adeb7874b9f (patch)
tree2e7133b8a2a8971c7d56414f54f7b57b96af0fb7
parentae31d6c7cbc847a93aadb521b6112b6238474a0a (diff)
Add a quick check to the Enum-forgiveness mode
Check in lookupUnqualifiedOrOldEnum() whether the name starts with a character to avoid looking up dunder/_slots attributes. Task-number: PYSIDE-1735 Change-Id: I989ddd3a89ec24809c640a492754a6ab179664de Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> (cherry picked from commit 090ce94f241496cdaac68eec4e7175b3e3395764) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--sources/shiboken6/libshiboken/sbkfeature_base.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/sources/shiboken6/libshiboken/sbkfeature_base.cpp b/sources/shiboken6/libshiboken/sbkfeature_base.cpp
index 41e2aaa5b..906df8e19 100644
--- a/sources/shiboken6/libshiboken/sbkfeature_base.cpp
+++ b/sources/shiboken6/libshiboken/sbkfeature_base.cpp
@@ -12,6 +12,8 @@
#include "sbkfeature_base.h"
#include "gilstate.h"
+#include <cctype>
+
using namespace Shiboken;
extern "C"
@@ -199,6 +201,9 @@ static PyObject *lookupUnqualifiedOrOldEnum(PyTypeObject *type, PyObject *name)
// MRO has been observed to be 0 in case of errors with QML decorators
if (type == nullptr || type->tp_mro == nullptr)
return nullptr;
+ // Quick Check: Avoid "__..", "_slots", etc.
+ if (std::isalpha(Shiboken::String::toCString(name)[0]) == 0)
+ return nullptr;
static PyTypeObject *const EnumMeta = getPyEnumMeta();
static PyObject *const _member_map_ = String::createStaticString("_member_map_");
// This is similar to `find_name_in_mro`, but instead of looking directly into