From 54f48761deba04f8ac68b601894d31bdabee3fd6 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Fri, 1 Mar 2019 15:18:45 +0100 Subject: Amend The Python 3.5 Fix After the bug found in PYSIDE-928, the contextlib problem of Python 3.5 also vanished. What remains is the crash on shutdown which is caused by module 'testbinding'. Task-number: PYSIDE-953 Change-Id: I07f18fa468fdb0758ee4e4b7663c3a42bec42822 Reviewed-by: Cristian Maureira-Fredes --- sources/pyside2/PySide2/support/generate_pyi.py | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'sources/pyside2/PySide2') diff --git a/sources/pyside2/PySide2/support/generate_pyi.py b/sources/pyside2/PySide2/support/generate_pyi.py index 21ef841fe..a92ee76f0 100644 --- a/sources/pyside2/PySide2/support/generate_pyi.py +++ b/sources/pyside2/PySide2/support/generate_pyi.py @@ -53,13 +53,6 @@ import re import subprocess import argparse import glob -# PYSIDE-953: Use a newer contextlib for Python 3.5 -skip_creation = False -if sys.version_info[:2] == (3, 5): - try: - import PySide2.support.signature # gets new contextlib - except: - skip_creation = True from contextlib import contextmanager from textwrap import dedent @@ -279,9 +272,6 @@ def single_process(lockdir): def generate_all_pyi(outpath, options): - if skip_creation: - logger.warn("Sorry, we cannot create .pyi files with Python 3.5 while PySide") - logger.warn(" is not installed. Please run it by hand!") ps = os.pathsep if options.sys_path: # make sure to propagate the paths from sys_path to subprocesses -- cgit v1.2.3 From 26bfda67690bdfee008de689d28ad8026f2c7a3d Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Mon, 4 Mar 2019 17:38:52 +0100 Subject: Update link to shiboken's words of advise page Change-Id: Ie2c1c7b9feefb56a9e987f71806a2ce400578fe8 Reviewed-by: Alexandru Croitor --- sources/pyside2/PySide2/QtUiTools/typesystem_uitools.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sources/pyside2/PySide2') diff --git a/sources/pyside2/PySide2/QtUiTools/typesystem_uitools.xml b/sources/pyside2/PySide2/QtUiTools/typesystem_uitools.xml index 2cbe490aa..c3b800454 100644 --- a/sources/pyside2/PySide2/QtUiTools/typesystem_uitools.xml +++ b/sources/pyside2/PySide2/QtUiTools/typesystem_uitools.xml @@ -62,7 +62,7 @@ of the `.ui` file. (Remember that `duck punching virtual methods is an invitation for your own demise! - <http://www.pyside.org/docs/shiboken/wordsofadvice.html#duck-punching-and-virtual-methods>`_) + <https://doc.qt.io/qtforpython/shiboken2/wordsofadvice.html#duck-punching-and-virtual-methods>`_) Let's see an obvious example. If you want to create a new widget it's probable you'll end up overriding :class:`~PySide2.QtGui.QWidget`'s :meth:`~PySide2.QtGui.QWidget.paintEvent` method. -- cgit v1.2.3 From 80691fb41939ca0bb90819a25c5f6ef06850a9e2 Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Mon, 4 Mar 2019 12:23:51 +0100 Subject: Add ownership to QGraphicsItemGroup.addToGroup Change-Id: I0c3741133072762443d80663be02a70abf9cc9ef Fixes: PYSIDE-95 Reviewed-by: Friedemann Kleint Reviewed-by: Qt CI Bot --- sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'sources/pyside2/PySide2') diff --git a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml index c2c36d60f..a41a27c33 100644 --- a/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml +++ b/sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml @@ -610,7 +610,13 @@ - + + + + + + + -- cgit v1.2.3 From 45e3c96a8075d210b70eabdb2ef9c3f7f1ca17af Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Wed, 27 Feb 2019 16:54:31 +0100 Subject: Add toBytes() and BufferProtocol VoidPtr: Add toBytes() method that return a char* representation of the void* pointer. QByteArray: The current implementation only provided the Buffer Protocol for Python2, this patch includes the getbuffer implementation for Python3. Having a BufferProtocol implementation for Python3 allows the initialization of VoidPtr to get access to the internal content, so one can go back and forward with the representation of it: ba = QByteArray(b"Hello World") vp = VoidPtr(ba, ba.size()) vp.toBytes() # b"Hello World" The BufferProtocol was also changed for Python2 including the new buffer protocol (Py_TPFLAGS_HAVE_NEWBUFFER) function `bf_getbuffer`. A test case was included. Fixes: PYSIDE-934 Change-Id: I8936966da91b2dcc879c582cfc35e6a35f7a60b6 Reviewed-by: Qt CI Bot Reviewed-by: Alexandru Croitor --- sources/pyside2/PySide2/glue/qtcore.cpp | 46 ++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 7 deletions(-) (limited to 'sources/pyside2/PySide2') diff --git a/sources/pyside2/PySide2/glue/qtcore.cpp b/sources/pyside2/PySide2/glue/qtcore.cpp index 629484458..6259724c3 100644 --- a/sources/pyside2/PySide2/glue/qtcore.cpp +++ b/sources/pyside2/PySide2/glue/qtcore.cpp @@ -965,13 +965,33 @@ if (PyIndex_Check(_key)) { // @snippet qbytearray-msetitem // @snippet qbytearray-bufferprotocol -#if PY_VERSION_HEX < 0x03000000 - +extern "C" { // QByteArray buffer protocol functions // see: http://www.python.org/dev/peps/pep-3118/ -extern "C" { +static int SbkQByteArray_getbufferproc(PyObject* obj, Py_buffer *view, int flags) +{ + if (!view || !Shiboken::Object::isValid(obj)) + return -1; + + QByteArray* cppSelf = %CONVERTTOCPP[QByteArray*](obj); + view->obj = obj; + view->buf = reinterpret_cast(cppSelf->data()); + view->len = cppSelf->size(); + view->readonly = 0; + view->itemsize = 1; + view->format = const_cast("c"); + view->ndim = 1; + view->shape = NULL; + view->strides = &view->itemsize; + view->suboffsets = NULL; + view->internal = NULL; + + Py_XINCREF(obj); + return 0; +} +#if PY_VERSION_HEX < 0x03000000 static Py_ssize_t SbkQByteArray_segcountproc(PyObject* self, Py_ssize_t* lenp) { if (lenp) @@ -993,12 +1013,18 @@ PyBufferProcs SbkQByteArrayBufferProc = { /*bf_getreadbuffer*/ &SbkQByteArray_readbufferproc, /*bf_getwritebuffer*/ (writebufferproc) &SbkQByteArray_readbufferproc, /*bf_getsegcount*/ &SbkQByteArray_segcountproc, - /*bf_getcharbuffer*/ (charbufferproc) &SbkQByteArray_readbufferproc + /*bf_getcharbuffer*/ (charbufferproc) &SbkQByteArray_readbufferproc, + /*bf_getbuffer*/ (getbufferproc)SbkQByteArray_getbufferproc, }; +#else -} +static PyBufferProcs SbkQByteArrayBufferProc = { + /*bf_getbuffer*/ (getbufferproc)SbkQByteArray_getbufferproc, + /*bf_releasebuffer*/ (releasebufferproc)0, +}; #endif +} // @snippet qbytearray-bufferprotocol // @snippet qbytearray-operatorplus-1 @@ -1110,8 +1136,14 @@ if (PyBytes_Check(%PYARG_1)) { // @snippet qbytearray-py3 #if PY_VERSION_HEX < 0x03000000 - Shiboken::SbkType()->tp_as_buffer = &SbkQByteArrayBufferProc; - Shiboken::SbkType()->tp_flags |= Py_TPFLAGS_HAVE_GETCHARBUFFER; +Shiboken::SbkType()->tp_as_buffer = &SbkQByteArrayBufferProc; +Shiboken::SbkType()->tp_flags |= Py_TPFLAGS_HAVE_NEWBUFFER; +#else +#ifdef Py_LIMITED_API +PepType_AS_BUFFER(Shiboken::SbkType()) = &SbkQByteArrayBufferProc; +#else +Shiboken::SbkType()->tp_as_buffer = &SbkQByteArrayBufferProc; +#endif #endif // @snippet qbytearray-py3 -- cgit v1.2.3