aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/libshiboken/sbkstring.cpp
diff options
context:
space:
mode:
authorSimo Fält <simo.falt@qt.io>2023-06-29 15:19:20 +0300
committerSimo Fält <simo.falt@qt.io>2023-06-29 15:19:20 +0300
commit568797c36a73aecce050fd198353f31aa986bff9 (patch)
treee1781afe922c4b6327045134639a5c5d41b56300 /sources/shiboken2/libshiboken/sbkstring.cpp
parent643237181d15086816d38cdb17f18147c7ebcbd8 (diff)
parentc76c68a64bb4dce48017c61b4ca021dc6726f77b (diff)
Merge tag 'v5.15.11-lts' into tqtc/lts-5.15-opensourcev5.15.11-lts-lgpl
Qt For Python Release 5.15.11 Change-Id: Idbf9b792238244e185e39be4058a7a2c69458ce9
Diffstat (limited to 'sources/shiboken2/libshiboken/sbkstring.cpp')
-rw-r--r--sources/shiboken2/libshiboken/sbkstring.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/sources/shiboken2/libshiboken/sbkstring.cpp b/sources/shiboken2/libshiboken/sbkstring.cpp
index 077fb531b..0f83aeef0 100644
--- a/sources/shiboken2/libshiboken/sbkstring.cpp
+++ b/sources/shiboken2/libshiboken/sbkstring.cpp
@@ -41,8 +41,14 @@
#include "sbkstaticstrings_p.h"
#include "autodecref.h"
-#include <vector>
-#include <unordered_set>
+#if PY_VERSION_HEX >= 0x03000000
+# define USE_INTERN_STRINGS
+#endif
+
+#ifndef USE_INTERN_STRINGS
+# include <vector>
+# include <unordered_set>
+#endif
namespace Shiboken
{
@@ -233,6 +239,13 @@ Py_ssize_t len(PyObject *str)
// PyObject *attr = PyObject_GetAttr(obj, name());
//
+#ifdef USE_INTERN_STRINGS
+PyObject *createStaticString(const char *str)
+{
+ return PyUnicode_InternFromString(str);
+}
+#else
+
using StaticStrings = std::unordered_set<PyObject *>;
static void finalizeStaticStrings(); // forward
@@ -283,6 +296,8 @@ PyObject *createStaticString(const char *str)
return result;
}
+#endif // !USE_INTERN_STRINGS
+
///////////////////////////////////////////////////////////////////////
//
// PYSIDE-1019: Helper function for snake_case vs. camelCase names