From a3c1a50eb1577caf3715c47b00ca26312d235a80 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Fri, 15 Jul 2022 15:30:03 +0200 Subject: Shiboken: use the Python 3.11 buffer interface for Limited API Because the stable API includes now the bufferprocs, we add a warning to remove the special handling when the lowest version is 3.11 . Unfortunately, I see no other way to use the new buffer interface, because things must work with every Python runtime. But that also does no harm, since this is now in the stable API. And of course, we can remove the boring version check :) Also, an old shiboken error workaround could be removed. XXX No, the shiboken error still exists in RHEL Change-Id: I2fae8cabb2cf116a7365b9cf45618da5238c2ea7 Pick-to: 6.3 Task-number: PYSIDE-1960 Reviewed-by: Christian Tismer --- sources/pyside6/PySide6/glue/qtcore.cpp | 3 +-- sources/shiboken6/libshiboken/pep384impl.h | 7 ++----- .../shibokenmodule/files.dir/shibokensupport/signature/parser.py | 4 ++++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sources/pyside6/PySide6/glue/qtcore.cpp b/sources/pyside6/PySide6/glue/qtcore.cpp index a2625e65b..68fcdcd05 100644 --- a/sources/pyside6/PySide6/glue/qtcore.cpp +++ b/sources/pyside6/PySide6/glue/qtcore.cpp @@ -672,7 +672,7 @@ static int SbkQByteArray_getbufferproc(PyObject *obj, Py_buffer *view, int flags QByteArray * cppSelf = %CONVERTTOCPP[QByteArray *](obj); //XXX /|\ omitting this space crashes shiboken! - #ifdef Py_LIMITED_API +#ifdef Py_LIMITED_API view->obj = obj; view->buf = reinterpret_cast(cppSelf->data()); view->len = cppSelf->size(); @@ -903,7 +903,6 @@ auto *pyTimer = timerType->tp_new(Shiboken::SbkType(), emptyTuple, nullp timerType->tp_init(pyTimer, emptyTuple, nullptr); auto timer = %CONVERTTOCPP[QTimer *](pyTimer); -//XXX /|\ omitting this space crashes shiboken! Shiboken::AutoDecRef result( PyObject_CallMethod(pyTimer, "connect", "OsOs", pyTimer, diff --git a/sources/shiboken6/libshiboken/pep384impl.h b/sources/shiboken6/libshiboken/pep384impl.h index b5cf10962..05743fbba 100644 --- a/sources/shiboken6/libshiboken/pep384impl.h +++ b/sources/shiboken6/libshiboken/pep384impl.h @@ -305,11 +305,8 @@ LIBSHIBOKEN_API PyObject *PyRun_String(const char *, int, PyObject *, PyObject * // buffer functions. // But this is no problem as we check it's validity for every version. -#define PYTHON_BUFFER_VERSION_COMPATIBLE (PY_VERSION_HEX >= 0x03030000 && \ - PY_VERSION_HEX < 0x030C0000) -#if !PYTHON_BUFFER_VERSION_COMPATIBLE -# error Please check the buffer compatibility for this python version! -#endif +// PYSIDE-1960 The buffer interface is since Python 3.11 part of the stable +// API and we do not need to check the compatibility by hand anymore. typedef struct { getbufferproc bf_getbuffer; diff --git a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py index d5fd47e04..ffb8badb5 100644 --- a/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py +++ b/sources/shiboken6/shibokenmodule/files.dir/shibokensupport/signature/parser.py @@ -66,6 +66,10 @@ def _get_flag_enum_option(): if pyminver and pyminver >= (3, 8): warnings.warn(f"\n *** Python is at version {'.'.join(map(str, pyminver))} now. " f"The file pep384_issue33738.cpp should be removed ASAP! ***") + # PYSIDE-1960: Emit a warning when we may remove pep384_issue33738.cpp + if pyminver and pyminver >= (3, 11): + warnings.warn(f"\n *** Python is at version {'.'.join(map(str, pyminver))} now. " + f"The files bufferprocs_py37.(cpp|h) should be removed ASAP! ***") # PYSIDE-1735: Emit a warning when we may update enum_310.py if pymaxver and pymaxver > (3, 10): if sys.version_info >= (3, 11, 0) and sys.version_info.releaselevel == "final": -- cgit v1.2.3