diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2023-09-29 10:40:29 +0200 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2023-10-02 19:13:13 +0000 |
commit | 91798b8e2254191afa1381c2ad5e5cb06e0ec511 (patch) | |
tree | 3458f51f273f0722808430e98363e6bfa488f72c | |
parent | ea283a44027d9b493c8cc00fc85840aa67af09d8 (diff) |
Refactor _PepRuntimeVersion()
Reduce the number of static variables.
Task-number: PYSIDE-2230
Change-Id: I7d40aeb77051af2c93a2f7aa3d3ada917f095aeb
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Shyamnath Premnadh <Shyamnath.Premnadh@qt.io>
(cherry picked from commit cb067123b3f804c1e2994c4c37c3b5fc6376f914)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
(cherry picked from commit 3339dd49cad8d7e9c76b9d1e8a02debb1a35ba81)
-rw-r--r-- | sources/shiboken6/libshiboken/pep384impl.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/sources/shiboken6/libshiboken/pep384impl.cpp b/sources/shiboken6/libshiboken/pep384impl.cpp index 1e96a12eb..7b3c205ec 100644 --- a/sources/shiboken6/libshiboken/pep384impl.cpp +++ b/sources/shiboken6/libshiboken/pep384impl.cpp @@ -898,13 +898,18 @@ init_PepRuntime() PepRuntime_38_flag = 1; } +static long _GetPepRuntimeVersion() +{ + auto *version = PySys_GetObject("version_info"); + const auto major = PyLong_AsLong(PyTuple_GetItem(version, 0)); + const auto minor = PyLong_AsLong(PyTuple_GetItem(version, 1)); + const auto micro = PyLong_AsLong(PyTuple_GetItem(version, 2)); + return major << 16 | minor << 8 | micro; +} + long _PepRuntimeVersion() { - static auto *version = PySys_GetObject("version_info"); - static auto major = PyLong_AsLong(PyTuple_GetItem(version, 0)); - static auto minor = PyLong_AsLong(PyTuple_GetItem(version, 1)); - static auto micro = PyLong_AsLong(PyTuple_GetItem(version, 2)); - static auto number = major << 16 | minor << 8 | micro; + static const auto number = _GetPepRuntimeVersion(); return number; } |