From 69b2941196c88feac4191fa62f571da46cf61774 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Thu, 2 Jun 2022 14:54:47 +0200 Subject: [PATCH] Limited_API: Fix PyIndex_Check once and for all: avoid warning The Windows compiler is quite overzealous and complains if headers have different ordering in the used version, although the content seems to be identical. Instead of doing a tedious search, we simply rename the function. Task-number: PYSIDE-1797 Change-Id: I88a8eca882357ac31b9eb932c89013c51c5c75e4 Pick-to: 6.2 6.3 Reviewed-by: Friedemann Kleint --- sources/pyside2/PySide2/glue/qtcore.cpp | 4 ++-- sources/shiboken2/libshiboken/pep384_issue33738.cpp | 2 +- sources/shiboken2/libshiboken/pep384impl.h | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sources/pyside2/PySide2/glue/qtcore.cpp b/sources/pyside2/PySide2/glue/qtcore.cpp index 8a9aae8f7..0fb553720 100644 --- a/sources/pyside2/PySide2/glue/qtcore.cpp +++ b/sources/pyside2/PySide2/glue/qtcore.cpp @@ -918,7 +918,7 @@ if (ret > 0 && ((strcmp(%1, SIGNAL(destroyed())) == 0) || (strcmp(%1, SIGNAL(des // @snippet qregexp-replace // @snippet qbytearray-mgetitem -if (PyIndex_Check(_key)) { +if (PepIndex_Check(_key)) { Py_ssize_t _i; _i = PyNumber_AsSsize_t(_key, PyExc_IndexError); if (_i < 0 || _i >= %CPPSELF.size()) { @@ -969,7 +969,7 @@ if (PyIndex_Check(_key)) { // @snippet qbytearray-mgetitem // @snippet qbytearray-msetitem -if (PyIndex_Check(_key)) { +if (PepIndex_Check(_key)) { Py_ssize_t _i = PyNumber_AsSsize_t(_key, PyExc_IndexError); if (_i == -1 && PyErr_Occurred()) return -1; diff --git a/sources/shiboken2/libshiboken/pep384_issue33738.cpp b/sources/shiboken2/libshiboken/pep384_issue33738.cpp index 59713f2f5..aff91e8e7 100644 --- a/sources/shiboken2/libshiboken/pep384_issue33738.cpp +++ b/sources/shiboken2/libshiboken/pep384_issue33738.cpp @@ -142,7 +142,7 @@ static bool is_compatible_version() // There is an automatic warning about this in parser.py . // -LIBSHIBOKEN_API int PyIndex_Check(PyObject *obj) +LIBSHIBOKEN_API int PepIndex_Check(PyObject *obj) { static bool old_python_version = is_compatible_version(); if (old_python_version) { diff --git a/sources/shiboken2/libshiboken/pep384impl.h b/sources/shiboken2/libshiboken/pep384impl.h index a9728242b..3171d0e1e 100644 --- a/sources/shiboken2/libshiboken/pep384impl.h +++ b/sources/shiboken2/libshiboken/pep384impl.h @@ -144,11 +144,11 @@ typedef struct _typeobject { // PYSIDE-1797: This must be a runtime decision. // Remove that when the minimum Python version is 3.8, -// because the macro PyIndex_Check bug was fixed then. -/// FIXME: Remove PyIndex_Check and pep384_issue33738.cpp when Python 3.7 is gone. -#undef PyIndex_Check -LIBSHIBOKEN_API int PyIndex_Check(PyObject *obj); +// because the macro PepIndex_Check bug was fixed then. +/// FIXME: Remove PepIndex_Check and pep384_issue33738.cpp when Python 3.7 is gone. +LIBSHIBOKEN_API int PepIndex_Check(PyObject *obj); +#define PepIndex_Check(obj) PyIndex_Check(obj) #endif // Py_LIMITED_API struct SbkObjectTypePrivate;