diff options
author | Cristián Maureira-Fredes <[email protected]> | 2024-11-07 10:59:03 +0100 |
---|---|---|
committer | Cristián Maureira-Fredes <[email protected]> | 2024-11-08 08:33:38 +0100 |
commit | 57cf99afc5fcbc7608790a42471667ed6d7bdea3 (patch) | |
tree | 96f426bb1ff7b22c8d89679edd19ca1c7faf4469 /sources/shiboken6/libshiboken/helper.cpp | |
parent | fb13a26a76eba415e743d119d5d2782c607fee2f (diff) |
limited api: replace PySequence_Fast_GET_SIZE by PySequence_Size
PySequence_Fast_GET_SIZE is defined as:
(PyList_Check(o) ? PyList_GET_SIZE(o) : PyTuple_GET_SIZE(o))
and when using the Limited API we re-define the _GET_SIZE macro
to be the _Size function, and considering this is our standard
use case, the macro could be replaced directly by the function.
Replacing also some cases were int was used instead of Py_ssize_t
when using PySequence_Size.
Pick-to: 6.8
Change-Id: I31aecd571a1d8ea82a3441f0b9e16ee19f026b05
Reviewed-by: Friedemann Kleint <[email protected]>
Diffstat (limited to 'sources/shiboken6/libshiboken/helper.cpp')
-rw-r--r-- | sources/shiboken6/libshiboken/helper.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sources/shiboken6/libshiboken/helper.cpp b/sources/shiboken6/libshiboken/helper.cpp index f50136aff..dc81bbb29 100644 --- a/sources/shiboken6/libshiboken/helper.cpp +++ b/sources/shiboken6/libshiboken/helper.cpp @@ -481,8 +481,8 @@ bool listToArgcArgv(PyObject *argList, int *argc, char ***argv, const char *defa // Check all items Shiboken::AutoDecRef args(PySequence_Fast(argList, nullptr)); - int numArgs = int(PySequence_Fast_GET_SIZE(argList)); - for (int i = 0; i < numArgs; ++i) { + Py_ssize_t numArgs = PySequence_Size(argList); + for (Py_ssize_t i = 0; i < numArgs; ++i) { PyObject *item = PyList_GET_ITEM(args.object(), i); if (!PyBytes_Check(item) && !PyUnicode_Check(item)) return false; @@ -524,7 +524,7 @@ int *sequenceToIntArray(PyObject *obj, bool zeroTerminated) if (seq.isNull()) return nullptr; - Py_ssize_t size = PySequence_Fast_GET_SIZE(seq.object()); + Py_ssize_t size = PySequence_Size(seq.object()); int *array = new int[size + (zeroTerminated ? 1 : 0)]; for (int i = 0; i < size; i++) { |