diff options
Diffstat (limited to 'sources/pyside2')
-rw-r--r-- | sources/pyside2/PySide2/QtUiTools/typesystem_uitools.xml | 2 | ||||
-rw-r--r-- | sources/pyside2/PySide2/QtWidgets/typesystem_widgets_common.xml | 8 | ||||
-rw-r--r-- | sources/pyside2/PySide2/glue/qtcore.cpp | 46 | ||||
-rw-r--r-- | sources/pyside2/PySide2/support/generate_pyi.py | 10 | ||||
-rw-r--r-- | sources/pyside2/doc/CMakeLists.txt | 3 | ||||
-rw-r--r-- | sources/pyside2/doc/conf.py.in | 5 | ||||
-rw-r--r-- | sources/pyside2/tests/registry/init_platform.py | 6 | ||||
-rw-r--r-- | sources/pyside2/tests/support/voidptr_test.py | 18 |
8 files changed, 70 insertions, 28 deletions
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. 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 @@ <include file-name="QPair" location="global"/> </extra-includes> </object-type> - <object-type name="QGraphicsItemGroup"/> + <object-type name="QGraphicsItemGroup"> + <modify-function signature="addToGroup(QGraphicsItem*)"> + <modify-argument index="1"> + <parent index="this" action="add"/> + </modify-argument> + </modify-function> + </object-type> <object-type name="QGraphicsLineItem"/> <object-type name="QGraphicsPathItem"/> <object-type name="QGraphicsPixmapItem"> 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<void*>(cppSelf->data()); + view->len = cppSelf->size(); + view->readonly = 0; + view->itemsize = 1; + view->format = const_cast<char*>("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<QByteArray>()->tp_as_buffer = &SbkQByteArrayBufferProc; - Shiboken::SbkType<QByteArray>()->tp_flags |= Py_TPFLAGS_HAVE_GETCHARBUFFER; +Shiboken::SbkType<QByteArray>()->tp_as_buffer = &SbkQByteArrayBufferProc; +Shiboken::SbkType<QByteArray>()->tp_flags |= Py_TPFLAGS_HAVE_NEWBUFFER; +#else +#ifdef Py_LIMITED_API +PepType_AS_BUFFER(Shiboken::SbkType<QByteArray>()) = &SbkQByteArrayBufferProc; +#else +Shiboken::SbkType<QByteArray>()->tp_as_buffer = &SbkQByteArrayBufferProc; +#endif #endif // @snippet qbytearray-py3 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 diff --git a/sources/pyside2/doc/CMakeLists.txt b/sources/pyside2/doc/CMakeLists.txt index eb5200e85..b5bde885a 100644 --- a/sources/pyside2/doc/CMakeLists.txt +++ b/sources/pyside2/doc/CMakeLists.txt @@ -28,6 +28,8 @@ configure_file("pyside-config.qdocconf.in" "${CMAKE_CURRENT_LIST_DIR}/pyside-con file(READ "${pyside2_BINARY_DIR}/pyside2_global.h" docHeaderContents) file(READ "typesystem_doc.xml.in" typeSystemDocXmlContents) +set(HAS_WEBENGINE_WIDGETS 0) + foreach(moduleIn ${all_module_shortnames}) string(TOLOWER "${moduleIn}" lowerModuleIn) set(docConf "${CMAKE_CURRENT_LIST_DIR}/qtmodules/pyside-qt${lowerModuleIn}.qdocconf.in") @@ -45,6 +47,7 @@ foreach(moduleIn ${all_module_shortnames}) set(modules Multimedia "${moduleIn}") elseif ("${moduleIn}" STREQUAL "WebEngineWidgets") set(modules WebEngine WebEngineCore "${moduleIn}") + set(HAS_WEBENGINE_WIDGETS 1) else() set(modules "${moduleIn}") endif() diff --git a/sources/pyside2/doc/conf.py.in b/sources/pyside2/doc/conf.py.in index 99b74deef..33f408354 100644 --- a/sources/pyside2/doc/conf.py.in +++ b/sources/pyside2/doc/conf.py.in @@ -18,7 +18,8 @@ import sys, os # documentation root, use os.path.abspath to make it absolute, like shown here. sys.path.append('@CMAKE_CURRENT_SOURCE_DIR@') sys.path.append('@pyside_BINARY_DIR@') -sys.path.append('@CMAKE_CURRENT_SOURCE_DIR@/../../../examples/webenginewidgets/tabbedbrowser') +if @HAS_WEBENGINE_WIDGETS@: + sys.path.append('@CMAKE_CURRENT_SOURCE_DIR@/../../../examples/webenginewidgets/tabbedbrowser') # -- General configuration ----------------------------------------------------- @@ -170,3 +171,5 @@ html_show_sourcelink = False # Link to the shiboken2 sphinx project to enable linking # between the two projects. intersphinx_mapping = {'shiboken2': ('shiboken2','@CMAKE_BINARY_DIR@/../shiboken2/doc/html/objects.inv')} + +add_module_names = False diff --git a/sources/pyside2/tests/registry/init_platform.py b/sources/pyside2/tests/registry/init_platform.py index 6031dd2ad..a324c36a2 100644 --- a/sources/pyside2/tests/registry/init_platform.py +++ b/sources/pyside2/tests/registry/init_platform.py @@ -55,8 +55,7 @@ shiboken and pysidetest projects. import sys import os import re -# PYSIDE-953: Use a newer contextlib for Python 3.5 -# from contextlib import contextmanager +from contextlib import contextmanager from textwrap import dedent script_dir = os.path.normpath(os.path.join(__file__, *".. .. .. .. ..".split())) @@ -118,9 +117,6 @@ sys.path[:0] = [os.path.join(shiboken_build_dir, "shibokenmodule"), pyside_build_dir] import PySide2 -# PYSIDE-953: Use a newer contextlib for Python 3.5 -import PySide2.support.signature # new contextlib -from contextlib import contextmanager all_modules = list("PySide2." + x for x in PySide2.__all__) diff --git a/sources/pyside2/tests/support/voidptr_test.py b/sources/pyside2/tests/support/voidptr_test.py index 330788c63..c04022489 100644 --- a/sources/pyside2/tests/support/voidptr_test.py +++ b/sources/pyside2/tests/support/voidptr_test.py @@ -38,9 +38,21 @@ class PySide2Support(unittest.TestCase): # a C++ object, a wrapped Shiboken Object type, # an object implementing the Python Buffer interface, # or another VoidPtr object. - ba = QByteArray(b"Hello world") - voidptr = VoidPtr(ba) - self.assertIsInstance(voidptr, shiboken.VoidPtr) + + # Original content + b = b"Hello world" + ba = QByteArray(b) + vp = VoidPtr(ba, ba.size()) + self.assertIsInstance(vp, shiboken.VoidPtr) + + # Create QByteArray from voidptr byte interpretation + nba = QByteArray.fromRawData(vp.toBytes()) + # Compare original bytes to toBytes() + self.assertTrue(b, vp.toBytes()) + # Compare original with new QByteArray data + self.assertTrue(b, nba.data()) + # Convert original and new to str + self.assertTrue(str(b), str(nba)) if __name__ == '__main__': unittest.main() |