aboutsummaryrefslogtreecommitdiffstats
path: root/sources
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2019-10-31 08:22:55 +0100
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2019-10-31 08:23:11 +0100
commit1064a14bebdc27dd749d9ec91bce5aa88d7a5d0f (patch)
treeccae2dcf7db3cecfe5cb648c604aa4b007152ed4 /sources
parent67929d31c4ab91b357957a9a47c16a8a6b42cf52 (diff)
parent403cfed02b017d80361cdb5b9bba8c4aad7a14bf (diff)
Merge remote-tracking branch 'origin/5.13' into 5.14
Diffstat (limited to 'sources')
-rw-r--r--sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_common.xml11
-rw-r--r--sources/pyside2/PySide2/glue/qtcore.cpp43
-rw-r--r--sources/pyside2/PySide2/glue/qtmultimedia.cpp7
-rw-r--r--sources/pyside2/doc/conf.py.in2
-rw-r--r--sources/pyside2/doc/contents.rst1
-rw-r--r--sources/pyside2/doc/index.rst28
-rw-r--r--sources/pyside2/doc/modules.rst87
-rw-r--r--sources/pyside2/doc/overview.rst14
-rw-r--r--sources/pyside2/tests/QtCore/attr_cache_py3k.py6
-rw-r--r--sources/pyside2/tests/QtCore/qsettings_test.py46
-rw-r--r--sources/pyside2/tests/QtWidgets/bug_862.py33
-rw-r--r--sources/pyside2/tests/pysidetest/CMakeLists.txt2
-rw-r--r--sources/pyside2/tests/pysidetest/repr_test.py83
-rw-r--r--sources/pyside2/tests/pysidetest/testobject.cpp22
-rw-r--r--sources/pyside2/tests/pysidetest/testobject.h12
-rw-r--r--sources/pyside2/tests/pysidetest/typesystem_pysidetest.xml7
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp23
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h3
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetalang.h9
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testdtorinformation.cpp33
-rw-r--r--sources/shiboken2/ApiExtractor/tests/testdtorinformation.h1
-rw-r--r--sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp6
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp11
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.h2
-rw-r--r--sources/shiboken2/libshiboken/shibokenbuffer.cpp4
25 files changed, 397 insertions, 99 deletions
diff --git a/sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_common.xml b/sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_common.xml
index d44c89e96..0c1012136 100644
--- a/sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_common.xml
+++ b/sources/pyside2/PySide2/QtMultimedia/typesystem_multimedia_common.xml
@@ -82,10 +82,19 @@
<object-type name="QAbstractVideoSurface">
<enum-type name="Error"/>
</object-type>
- <object-type name="QAbstractVideoFilter"/>
+ <object-type name="QAbstractVideoFilter">
+ <modify-function signature="createFilterRunnable()">
+ <modify-argument index="return">
+ <define-ownership class="native" owner="c++"/>
+ </modify-argument>
+ </modify-function>
+ </object-type>
<value-type name="QVideoFrame">
<enum-type name="FieldType"/>
<enum-type name="PixelFormat"/>
+ <modify-function signature="bits()">
+ <inject-code file="../glue/qtmultimedia.cpp" snippet="qvideoframe-bits"/>
+ </modify-function>
<modify-function signature="bits(int)" remove="all"/>
<modify-function signature="bits(int)const" remove="all"/>
</value-type>
diff --git a/sources/pyside2/PySide2/glue/qtcore.cpp b/sources/pyside2/PySide2/glue/qtcore.cpp
index 4c798aef9..47b3dd6db 100644
--- a/sources/pyside2/PySide2/glue/qtcore.cpp
+++ b/sources/pyside2/PySide2/glue/qtcore.cpp
@@ -57,24 +57,39 @@ bool py2kStrCheck(PyObject *obj)
// @snippet pystring-check
// @snippet qsettings-value
-QVariant out = %CPPSELF.value(%1, %2);
+// If we enter the kwds, means that we have a defaultValue or
+// at least a type.
+// This avoids that we are passing '0' as defaultValue.
+// defaultValue can also be passed as positional argument,
+// not only as keyword.
+QVariant out;
+if (kwds || numArgs > 1)
+ out = %CPPSELF.value(%1, %2);
+else
+ out = %CPPSELF.value(%1);
+
PyTypeObject *typeObj = reinterpret_cast<PyTypeObject*>(%PYARG_3);
if (typeObj) {
if (typeObj == &PyList_Type) {
- QByteArrayList valuesList = out.toByteArray().split(',');
- const int valuesSize = valuesList.size();
- if (valuesSize > 0) {
- PyObject *list = PyList_New(valuesSize);
- for (int i = 0; i < valuesSize; i++) {
- PyObject *item = PyUnicode_FromString(valuesList[i].data());
- PyList_SET_ITEM(list, i, item);
- Py_DECREF(item);
- }
- %PYARG_0 = list;
+ QByteArray out_ba = out.toByteArray();
+ if (!out_ba.isEmpty()) {
+ QByteArrayList valuesList = out_ba.split(',');
+ const int valuesSize = valuesList.size();
+ if (valuesSize > 0) {
+ PyObject *list = PyList_New(valuesSize);
+ for (int i = 0; i < valuesSize; i++) {
+ PyObject *item = PyUnicode_FromString(valuesList[i].data());
+ PyList_SET_ITEM(list, i, item);
+ Py_DECREF(item);
+ }
+ %PYARG_0 = list;
+ } else {
+ %PYARG_0 = %CONVERTTOPYTHON[QVariant](out);
+ }
} else {
- %PYARG_0 = %CONVERTTOPYTHON[QVariant](out);
+ %PYARG_0 = PyList_New(0);
}
} else if (typeObj == &PyBytes_Type) {
QByteArray asByteArray = out.toByteArray();
@@ -94,11 +109,13 @@ if (typeObj) {
} else if (typeObj == &PyFloat_Type) {
float asFloat = out.toFloat();
%PYARG_0 = PyFloat_FromDouble(asFloat);
+ } else if (typeObj == &PyBool_Type) {
+ %PYARG_0 = out.toBool() ? Py_True : Py_False;
}
// TODO: PyDict_Type and PyTuple_Type
}
else {
- if (out == 0)
+ if (!out.isValid())
%PYARG_0 = Py_None;
else
%PYARG_0 = %CONVERTTOPYTHON[QVariant](out);
diff --git a/sources/pyside2/PySide2/glue/qtmultimedia.cpp b/sources/pyside2/PySide2/glue/qtmultimedia.cpp
index 5a3f3a5e7..cbe1367cb 100644
--- a/sources/pyside2/PySide2/glue/qtmultimedia.cpp
+++ b/sources/pyside2/PySide2/glue/qtmultimedia.cpp
@@ -44,3 +44,10 @@ QObject * upcastedArg = %CONVERTTOCPP[QObject *](%PYARG_1);
%CPPSELF.%FUNCTION_NAME(reinterpret_cast< %ARG1_TYPE >(upcastedArg));
%END_ALLOW_THREADS
// @snippet upcast
+
+// @snippet qvideoframe-bits
+%BEGIN_ALLOW_THREADS
+%RETURN_TYPE %0 = %CPPSELF.%FUNCTION_NAME();
+%END_ALLOW_THREADS
+%PYARG_0 = Shiboken::Buffer::newObject(%0, %CPPSELF.bytesPerLine() * %CPPSELF.height(), Shiboken::Buffer::ReadWrite);
+// @snippet qvideoframe-bits
diff --git a/sources/pyside2/doc/conf.py.in b/sources/pyside2/doc/conf.py.in
index 33f408354..e197b1ac7 100644
--- a/sources/pyside2/doc/conf.py.in
+++ b/sources/pyside2/doc/conf.py.in
@@ -75,7 +75,7 @@ release = '@BINDING_API_VERSION_FULL@'
# List of directories, relative to source directory, that shouldn't be searched
# for source files.
-exclude_trees = ['_build', 'extras']
+exclude_patterns = ['_build', 'extras']
# The reST default role (used for this markup: `text`) to use for all documents.
#default_role = None
diff --git a/sources/pyside2/doc/contents.rst b/sources/pyside2/doc/contents.rst
index 675a5b73a..c4867f250 100644
--- a/sources/pyside2/doc/contents.rst
+++ b/sources/pyside2/doc/contents.rst
@@ -11,6 +11,7 @@
deployment.rst
pysideapi2.rst
licenses.rst
+ modules.rst
Module Index
============
diff --git a/sources/pyside2/doc/index.rst b/sources/pyside2/doc/index.rst
index b0bb1d19c..acc1d6d40 100644
--- a/sources/pyside2/doc/index.rst
+++ b/sources/pyside2/doc/index.rst
@@ -24,23 +24,23 @@ Basic modules
-------------
These are the main modules that will help you build a Widget based UI.
- `Qt Core <PySide2/QtCore/index.html>`_
+ :mod:`Qt Core <PySide2.QtCore>`
Provides core non-GUI functionality, like signal and slots, properties, base classes of item models, serialization, etc.
- `Qt Gui <PySide2/QtGui/index.html>`_
+ :mod:`Qt Gui <PySide2.QtGui>`
Extends QtCore with GUI functionality: Events, windows and screens, OpenGL and raster-based 2D painting, images.
- `Qt Widgets <PySide2/QtWidgets/index.html>`_
+ :mod:`Qt Widgets <PySide2.QtWidgets>`
Ready to use Widgets for your application, including also graphical elements for your UI.
QML and Qt Quick
----------------
- If you want to use the `Qml Language <https://doc.qt.io/qt-5/qmlapplications.html>`, these
+ If you want to use the `Qml Language <https://doc.qt.io/qt-5.qmlapplications>`, these
modules will help you interact with it from Python.
- `Qt Qml <PySide2/QtQml/index.html>`_
+ :mod:`Qt Qml <PySide2.QtQml>`
Base Python API to interact with the QML module.
- `Qt Quick <PySide2/QtQuick/index.html>`_
+ :mod:`Qt Quick <PySide2.QtQuick>`
Provides classes for embedding Qt Quick in Qt applications.
- `Qt QuickWidgets <PySide2/QtQuickWidgets/index.html>`_
+ :mod:`Qt QuickWidgets <PySide2.QtQuickWidgets>`
Provides the QQuickWidget class for embedding Qt Quick in widget-based applications.
Data visualization
@@ -49,9 +49,9 @@ Data visualization
Charts, diagrams, animations: these modules provide a large amount
of classes that can help you include these elements in your UI.
- `Qt Charts <PySide2/QtCharts/index.html>`_
+ :mod:`Qt Charts <PySide2.QtCharts>`
Provides a set of easy to use chart components.
- `Qt DataVisualization <PySide2/QtDataVisualization/index.html>`_
+ :mod:`Qt DataVisualization <PySide2.QtDataVisualization>`
Provides a way to visualize data in 3D as bar, scatter, and surface graphs.
Multimedia
@@ -60,9 +60,9 @@ Multimedia
Audio, video, and hardware interaction: check these modules if you are
looking for multimedia solutions.
- `Qt Multimedia <PySide2/QtMultimedia/index.html>`_
+ :mod:`Qt Multimedia <PySide2.QtMultimedia>`
Provides low-level multimedia functionality.
- `Qt MultimediaWidgets <PySide2/QtMultimediaWidgets/index.html>`_
+ :mod:`Qt MultimediaWidgets <PySide2.QtMultimediaWidgets>`
Provides the widget-based multimedia API.
WebEngine
@@ -71,9 +71,9 @@ WebEngine
If your project is based on a browser or the features around web
based applications, these modules will help you to interact with them.
- `Qt WebEngineWidgets <PySide2/QtWebEngineWidgets/index.html>`_
+ :mod:`Qt WebEngineWidgets <PySide2.QtWebEngineWidgets>`
Provides widgets that can handle web content.
- `Qt WebChannel <PySide2/QtWebChannel/index.html>`_
+ :mod:`Qt WebChannel <PySide2.QtWebChannel>`
Enables peer-to-peer communication between a server and a client
(HTML/JavaScript or QML application).
@@ -83,5 +83,5 @@ All the modules
There are many other modules currently supported by |pymodname|,
here you can find a complete list of them.
- `Check all the modules <modules.html>`_
+ :doc:`Check all the modules <modules>`
Display a table with all the currently supported Qt modules.
diff --git a/sources/pyside2/doc/modules.rst b/sources/pyside2/doc/modules.rst
index 1d6564300..6741b465d 100644
--- a/sources/pyside2/doc/modules.rst
+++ b/sources/pyside2/doc/modules.rst
@@ -1,94 +1,101 @@
Qt Modules
===========
+.. toctree::
+ :hidden:
+ :glob:
+
+ PySide2/Qt**
+
.. list-table::
:widths: 150, 150
:align: left
- * - `Qt Core <PySide2/QtCore/index.html>`_
+ * - :mod:`Qt Core <PySide2.QtCore>`
Provides core non-GUI functionality.
- - `Qt 3D Animation <PySide2/Qt3DAnimation/index.html>`_
+ - :mod:`Qt 3D Animation <PySide2.Qt3DAnimation>`
Provides basic elements required to animate 3D objects.
- * - `Qt Gui <PySide2/QtGui/index.html>`_
+ * - :mod:`Qt Gui <PySide2.QtGui>`
Extends QtCore with GUI functionality.
- - `Qt Help <PySide2/QtHelp/index.html>`_
+ - :mod:`Qt Help <PySide2.QtHelp>`
Provides classes for integrating online documentation in applications.
- * - `Qt Network <PySide2/QtNetwork/index.html>`_
+ * - :mod:`Qt Network <PySide2.QtNetwork>`
Offers classes that let you to write TCP/IP clients and servers.
- - `Qt OpenGL <PySide2/QtOpenGL/index.html>`_
+ - :mod:`Qt OpenGL <PySide2.QtOpenGL>`
Offers classes that make it easy to use OpenGL in Qt applications.
- * - `Qt PrintSupport <PySide2/QtPrintSupport/index.html>`_
+ * - :mod:`Qt PrintSupport <PySide2.QtPrintSupport>`
Provides extensive cross-platform support for printing.
- - `Qt Qml <PySide2/QtQml/index.html>`_
+ - :mod:`Qt Qml <PySide2.QtQml>`
Python API for Qt QML.
- * - `Qt Charts <PySide2/QtCharts/index.html>`_
+ * - :mod:`Qt Charts <PySide2.QtCharts>`
Provides a set of easy to use chart components.
- - `Qt Quick <PySide2/QtQuick/index.html>`_
+ - :mod:`Qt Quick <PySide2.QtQuick>`
Provides classes for embedding Qt Quick in Qt applications.
- * - `Qt DataVisualization <PySide2/QtDataVisualization/index.html>`_
+ * - :mod:`Qt DataVisualization <PySide2.QtDataVisualization>`
Provides a way to visualize data in 3D as bar, scatter, and surface graphs.
- - `Qt QuickWidgets <PySide2/QtQuickWidgets/index.html>`_
+ - :mod:`Qt QuickWidgets <PySide2.QtQuickWidgets>`
Provides the QQuickWidget class for embedding Qt Quick in widget-based applications.
- * - `Qt TextToSpeech <PySide2/QtTextToSpeech/index.html>`_
+ * - :mod:`Qt TextToSpeech <PySide2.QtTextToSpeech>`
Provides API to access text-to-speech engines.
- - `Qt Sql <PySide2/QtSql/index.html>`_
+ - :mod:`Qt Sql <PySide2.QtSql>`
Helps you provide seamless database integration to your Qt applications.
- * - `Qt Multimedia <PySide2/QtMultimedia/index.html>`_
+ * - :mod:`Qt Multimedia <PySide2.QtMultimedia>`
Provides low-level multimedia functionality.
- - `Qt MultimediaWidgets <PySide2/QtMultimediaWidgets/index.html>`_
+ - :mod:`Qt MultimediaWidgets <PySide2.QtMultimediaWidgets>`
Provides the widget-based multimedia API.
- * - `Qt MacExtras <PySide2/QtMacExtras/index.html>`_
+ * - :mod:`Qt MacExtras <PySide2.QtMacExtras>`
Provides classes and functions specific to
macOS and iOS operating systems.
- - `Qt Svg <PySide2/QtSvg/index.html>`_
+ - :mod:`Qt Svg <PySide2.QtSvg>`
Provides classes for displaying the contents of SVG files.
- * - `Qt UiTools <PySide2/QtUiTools/index.html>`_
+ * - :mod:`Qt UiTools <PySide2.QtUiTools>`
Provides classes to handle forms created with Qt Designer.
- - `Qt Test <PySide2/QtTest/index.html>`_
+ - :mod:`Qt Test <PySide2.QtTest>`
Provides classes for unit testing Qt applications and libraries.
- * - `Qt Concurrent <PySide2/QtConcurrent/index.html>`_
+ * - :mod:`Qt Concurrent <PySide2.QtConcurrent>`
Provides high-level APIs that make it possible
to write multi-threaded programs without using low-level threading
primitives such as mutexes, read-write locks, wait conditions, or semaphores.
- - `Qt AxContainer <PySide2/QtAxContainer/index.html>`_
+ - :mod:`Qt AxContainer <PySide2.QtAxContainer>`
Provides QAxObject and QAxWidget which act as
containers for COM objects and ActiveX controls.
- * - `Qt WebEngineCore <PySide2/QtWebEngineCore/index.html>`_
+ * - :mod:`Qt WebEngineCore <PySide2.QtWebEngineCore>`
Provides the core functionality to integrate web content.
- - `Qt WebEngineWidgets <PySide2/QtWebEngineWidgets/index.html>`_
+ - :mod:`Qt WebEngineWidgets <PySide2.QtWebEngineWidgets>`
Provides widgets that can handle web content.
- * - `Qt WebChannel <PySide2/QtWebChannel/index.html>`_
+ * - :mod:`Qt WebChannel <PySide2.QtWebChannel>`
Enables peer-to-peer communication between a server and a client
(HTML/JavaScript or QML application).
- - `Qt WebSockets <PySide2/QtWebSockets/index.html>`_
+ - :mod:`Qt WebSockets <PySide2.QtWebSockets>`
Provides interfaces that enable Qt applications
to act as a server that can process WebSocket requests, or a client that
can consume data received from the server, or both.
- * - `Qt Widgets <PySide2/QtWidgets/index.html>`_
+ * - :mod:`Qt Widgets <PySide2.QtWidgets>`
Extends Qt GUI with C++ widget functionality.
- - `Qt WinExtras <PySide2/QtWinExtras/index.html>`_
+ - :mod:`Qt WinExtras <PySide2.QtWinExtras>`
Provides classes and functions for using some Windows APIs in a Qt way.
- * - `Qt X11Extras <PySide2/QtX11Extras/index.html>`_
+ * - :mod:`Qt X11Extras <PySide2.QtX11Extras>`
Provides information about the X display configuration.
- - `Qt Xml <PySide2/QtXml/index.html>`_
+ - :mod:`Qt Xml <PySide2.QtXml>`
Provides C++ implementations of SAX and DOM.
- * - `Qt XmlPatterns <PySide2/QtXmlPatterns/index.html>`_
+ * - :mod:`Qt XmlPatterns <PySide2.QtXmlPatterns>`
Provides support for XPath, XQuery, XSLTi, and XML Schema validation.
- - `Qt 3D Core <PySide2/Qt3DCore/index.html>`_
+ - :mod:`Qt 3D Core <PySide2.Qt3DCore>`
Contains functionality to support near-realtime simulation systems.
- * - `Qt 3D Extras <PySide2/Qt3DExtras/index.html>`_
+ * - :mod:`Qt 3D Extras <PySide2.Qt3DExtras>`
Provides a set of prebuilt elements to help you get started with Qt 3D.
- - `Qt 3D Input <PySide2/Qt3DInput/index.html>`_
+ - :mod:`Qt 3D Input <PySide2.Qt3DInput>`
Provides classes for handling user input in applications using Qt 3D.
- * - `Qt 3D Logic <PySide2/Qt3DLogic/index.html>`_
+ * - :mod:`Qt 3D Logic <PySide2.Qt3DLogic>`
Enables synchronizing frames with the Qt 3D backend.
- - `Qt 3D Render <PySide2/Qt3DRender/index.html>`_
+ - :mod:`Qt 3D Render <PySide2.Qt3DRender>`
Contains functionality to support 2D and 3D rendering using Qt 3D.
- * - `Qt Positioning <PySide2/QtPositioning/index.html>`_
+ * - :mod:`Qt Positioning <PySide2.QtPositioning>`
Provides positioning information via QML and Python interfaces.
- - `Qt Location <PySide2/QtLocation/index.html>`_
+ - :mod:`Qt Location <PySide2.QtLocation>`
Helps you create viable mapping solutions using the data available from some of the popular location services.
- * - `Qt Sensors <PySide2/QtSensors/index.html>`_
+ * - :mod:`Qt Sensors <PySide2.QtSensors>`
Provides access to sensor hardware via QML and Python interfaces and a motion gesture recognition API for devices.
- - `Qt Scxml <PySide2/QtScxml/index.html>`_
+ - :mod:`Qt Scxml <PySide2.QtScxml>`
Provides classes to create and use state machines from SCXML files.
+
diff --git a/sources/pyside2/doc/overview.rst b/sources/pyside2/doc/overview.rst
index e8a8ace00..86c3a54fe 100644
--- a/sources/pyside2/doc/overview.rst
+++ b/sources/pyside2/doc/overview.rst
@@ -40,3 +40,17 @@ A simple Hello World example in PySide2 looks like this:
label = QLabel("Hello World")
label.show()
sys.exit(app.exec_())
+
+
+Additional overviews
+--------------------
+
+These additional topics provide detailed information about
+several Qt-specific features:
+
+.. toctree::
+ :titlesonly:
+ :glob:
+
+ overviews/*
+
diff --git a/sources/pyside2/tests/QtCore/attr_cache_py3k.py b/sources/pyside2/tests/QtCore/attr_cache_py3k.py
index ec0575b02..f9761a9d3 100644
--- a/sources/pyside2/tests/QtCore/attr_cache_py3k.py
+++ b/sources/pyside2/tests/QtCore/attr_cache_py3k.py
@@ -56,9 +56,9 @@ class A(QObject):
def test(cls):
cls.instance
cls.instance = cls()
- assert "<__main__.A object " in repr(cls.__dict__['instance'])
- assert "<__main__.A object " in repr(cls.instance)
- assert "<__main__.A object " in repr(type.__getattribute__(cls, 'instance'))
+ assert "<__main__.A(0x" in repr(cls.__dict__['instance'])
+ assert "<__main__.A(0x" in repr(cls.instance)
+ assert "<__main__.A(0x" in repr(type.__getattribute__(cls, 'instance'))
if __name__ == "__main__":
diff --git a/sources/pyside2/tests/QtCore/qsettings_test.py b/sources/pyside2/tests/QtCore/qsettings_test.py
index 6d64b0db3..36a4c3c62 100644
--- a/sources/pyside2/tests/QtCore/qsettings_test.py
+++ b/sources/pyside2/tests/QtCore/qsettings_test.py
@@ -55,15 +55,55 @@ class TestQSettings(unittest.TestCase):
def testDefaultValueConversion(self):
settings = QSettings('foo.ini', QSettings.IniFormat)
- r = settings.value('lala', 22)
+ settings.setValue('zero_value', 0)
+ settings.setValue('empty_list', [])
+ settings.setValue('bool1', False)
+ settings.setValue('bool2', True)
+ del settings
+
+ # Loading values already set
+ settings = QSettings('foo.ini', QSettings.IniFormat)
+
+ # Getting value that doesn't exist
+ r = settings.value("variable")
+ self.assertEqual(type(r), type(None))
+
+ # Handling zero value
+ r = settings.value('zero_value')
if py3k.IS_PY3K:
self.assertEqual(type(r), int)
else:
self.assertEqual(type(r), long)
- r = settings.value('lala', 22, type=str)
- self.assertEqual(type(r), str)
+ r = settings.value('zero_value', type=int)
+ self.assertEqual(type(r), int)
+
+ # Empty list
+ r = settings.value('empty_list')
+ self.assertTrue(len(r) == 0)
+ self.assertEqual(type(r), list)
+
+ r = settings.value('empty_list', type=list)
+ self.assertTrue(len(r) == 0)
+ self.assertEqual(type(r), list)
+
+ # Booleans
+ r = settings.value('bool1')
+ self.assertEqual(type(r), bool)
+
+ r = settings.value('bool2')
+ self.assertEqual(type(r), bool)
+
+ r = settings.value('bool1', type=bool)
+ self.assertEqual(type(r), bool)
+
+ r = settings.value('bool2', type=int)
+ self.assertEqual(type(r), int)
+
+ r = settings.value('bool2', type=bool)
+ self.assertEqual(type(r), bool)
+ # Not set variable, but with default value
r = settings.value('lala', 22, type=bytes)
self.assertEqual(type(r), bytes)
diff --git a/sources/pyside2/tests/QtWidgets/bug_862.py b/sources/pyside2/tests/QtWidgets/bug_862.py
index ac0325536..4621fc3b4 100644
--- a/sources/pyside2/tests/QtWidgets/bug_862.py
+++ b/sources/pyside2/tests/QtWidgets/bug_862.py
@@ -26,6 +26,29 @@
##
#############################################################################
+
+#
+# Test for bug 862, original description was:
+#
+# print seems to be broken at least for QGraphicsItems-derived objects. The
+# attached code shows:
+#
+# <__main__.MyQObject object at 0xf99f38>
+# <__main__.MyQWidget object at 0xf99f38>
+# <PySide.QtGui.MyQGraphicsObject (this = 0x11c0d60 , parent = 0x0 , pos =
+# QPointF(0, 0) , z = 0 , flags = ( ) ) at 0xf99f38>
+# <PySide.QtGui.QGraphicsItem (this = 0x11c2e60 , parent = 0x0 , pos = QPointF(0,
+# 0) , z = 0 , flags = ( ) ) at 0xf99f38>
+#
+# Where it should be showing something like:
+#
+# <__main__.MyQObject object at 0x7f55cf226c20>
+# <__main__.MyQWidget object at 0x7f55cf226c20>
+# <__main__.MyQGraphicsObject object at 0x7f55cf226c20>
+# <__main__.MyQGraphicsItem object at 0x7f55cf226c20>
+#
+
+
from PySide2.QtCore import QObject
from PySide2.QtWidgets import *
import PySide2.QtCore
@@ -53,14 +76,14 @@ class TestRepr (unittest.TestCase):
app = QApplication([])
- self.assertEqual("<__main__.MyQObject object at ", repr(MyQObject())[:30])
- self.assertEqual("<__main__.MyQWidget object at ", repr(MyQWidget())[:30])
+ self.assertEqual("<__main__.MyQObject(0x", repr(MyQObject())[:22])
+ self.assertEqual("<__main__.MyQWidget(0x", repr(MyQWidget())[:22])
self.assertEqual("<__main__.MyQGraphicsObject(0x", repr(MyQGraphicsObject())[:30])
self.assertEqual("<__main__.MyQGraphicsItem(0x", repr(MyQGraphicsItem())[:28])
- self.assertEqual("<PySide2.QtCore.QObject object at ", repr(QObject())[:34])
- self.assertEqual("<PySide2.QtCore.QObject object at ", repr(PySide2.QtCore.QObject())[:34])
- self.assertEqual("<PySide2.QtWidgets.QWidget object at ", repr(QWidget())[:37])
+ self.assertEqual("<PySide2.QtCore.QObject(0x", repr(QObject())[:26])
+ self.assertEqual("<PySide2.QtCore.QObject(0x", repr(PySide2.QtCore.QObject())[:26])
+ self.assertEqual("<PySide2.QtWidgets.QWidget(0x", repr(QWidget())[:29])
self.assertEqual("<PySide2.QtWidgets.QGraphicsWidget(0x", repr(QGraphicsWidget())[:37])
if __name__ == "__main__":
diff --git a/sources/pyside2/tests/pysidetest/CMakeLists.txt b/sources/pyside2/tests/pysidetest/CMakeLists.txt
index f81de55f7..4dcf9b89c 100644
--- a/sources/pyside2/tests/pysidetest/CMakeLists.txt
+++ b/sources/pyside2/tests/pysidetest/CMakeLists.txt
@@ -30,6 +30,7 @@ ${CMAKE_CURRENT_BINARY_DIR}/testbinding/testobject_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/testbinding/intvalue_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/testbinding/pysidecpp_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/testbinding/pysidecpp_testobjectwithnamespace_wrapper.cpp
+${CMAKE_CURRENT_BINARY_DIR}/testbinding/pysidecpp_testobject2withnamespace_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/testbinding/pysidecpp2_testobjectwithoutnamespace_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/testbinding/testview_wrapper.cpp
${CMAKE_CURRENT_BINARY_DIR}/testbinding/testbinding_module_wrapper.cpp
@@ -137,6 +138,7 @@ PYSIDE_TEST(new_inherited_functions_test.py)
PYSIDE_TEST(notify_id.py)
PYSIDE_TEST(qapp_like_a_macro_test.py)
PYSIDE_TEST(qvariant_test.py)
+PYSIDE_TEST(repr_test.py)
PYSIDE_TEST(signal_slot_warning.py)
PYSIDE_TEST(signalandnamespace_test.py)
PYSIDE_TEST(signalemissionfrompython_test.py)
diff --git a/sources/pyside2/tests/pysidetest/repr_test.py b/sources/pyside2/tests/pysidetest/repr_test.py
new file mode 100644
index 000000000..295084f17
--- /dev/null
+++ b/sources/pyside2/tests/pysidetest/repr_test.py
@@ -0,0 +1,83 @@
+# -*- coding: utf-8 -*-
+
+#############################################################################
+##
+## Copyright (C) 2019 The Qt Company Ltd.
+## Copyright (C) 2019 Andreas Beckermann
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of Qt for Python.
+##
+## $QT_BEGIN_LICENSE:LGPL$
+## Commercial License Usage
+## Licensees holding valid commercial Qt licenses may use this file in
+## accordance with the commercial license agreement provided with the
+## Software or, alternatively, in accordance with the terms contained in
+## a written agreement between you and The Qt Company. For licensing terms
+## and conditions see https://www.qt.io/terms-conditions. For further
+## information use the contact form at https://www.qt.io/contact-us.
+##
+## GNU Lesser General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU Lesser
+## General Public License version 3 as published by the Free Software
+## Foundation and appearing in the file LICENSE.LGPL3 included in the
+## packaging of this file. Please review the following information to
+## ensure the GNU Lesser General Public License version 3 requirements
+## will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+##
+## GNU General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 2.0 or (at your option) the GNU General
+## Public license version 3 or any later version approved by the KDE Free
+## Qt Foundation. The licenses are as published by the Free Software
+## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+## included in the packaging of this file. Please review the following
+## information to ensure the GNU General Public License requirements will
+## be met: https://www.gnu.org/licenses/gpl-2.0.html and
+## https://www.gnu.org/licenses/gpl-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from testbinding import PySideCPP, TestObject
+
+class QObjectDerivedReprTest(unittest.TestCase):
+ """Test the __repr__ implementation of QObject derived classes"""
+
+ def testReprWithoutNamespace(self):
+ """Test that classes outside a namespace that have a operator<<(QDebug,...) defined use that
+ for __repr__"""
+ t = TestObject(123)
+
+ # We don't define __str__, so str(q) should call __repr__
+ self.assertEqual(t.__repr__(), str(t))
+
+ # __repr__ should use the operator<<(QDebug,...) implementation
+ self.assertIn('TestObject(id=123)', str(t))
+
+ def testReprWithNamespace(self):
+ """Test that classes inside a namespace that have a operator<<(QDebug,...) defined use that
+ for __repr__"""
+ t = PySideCPP.TestObjectWithNamespace(None)
+
+ # We don't define __str__, so str(q) should call __repr__
+ self.assertEqual(t.__repr__(), str(t))
+
+ # __repr__ should use the operator<<(QDebug,...) implementation
+ self.assertIn('TestObjectWithNamespace("TestObjectWithNamespace")', str(t))
+
+ def testReprInject(self):
+ """Test that injecting __repr__ via typesystem overrides the operator<<(QDebug, ...)"""
+ t = PySideCPP.TestObject2WithNamespace(None)
+
+ # We don't define __str__, so str(q) should call __repr__
+ self.assertEqual(t.__repr__(), str(t))
+
+ # __repr__ should use the operator<<(QDebug,...) implementation
+ self.assertEqual(str(t), "TestObject2WithNamespace(injected_repr)")
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/pyside2/tests/pysidetest/testobject.cpp b/sources/pyside2/tests/pysidetest/testobject.cpp
index 03a7a965c..441ae872f 100644
--- a/sources/pyside2/tests/pysidetest/testobject.cpp
+++ b/sources/pyside2/tests/pysidetest/testobject.cpp
@@ -52,3 +52,25 @@ void TestObject::emitSignalWithTypedefValue(int value)
{
emit signalWithTypedefValue(TypedefValue(value));
}
+
+QDebug operator<<(QDebug dbg, TestObject& testObject)
+{
+ QDebugStateSaver saver(dbg);
+ dbg.nospace() << "TestObject(id=" << testObject.idValue() << ") ";
+ return dbg;
+}
+
+namespace PySideCPP {
+ QDebug operator<<(QDebug dbg, TestObjectWithNamespace& testObject)
+ {
+ QDebugStateSaver saver(dbg);
+ dbg.nospace() << "TestObjectWithNamespace(" << testObject.name() << ") ";
+ return dbg;
+ }
+ QDebug operator<<(QDebug dbg, TestObject2WithNamespace& testObject)
+ {
+ QDebugStateSaver saver(dbg);
+ dbg.nospace() << "TestObject2WithNamespace(" << testObject.name() << ") ";
+ return dbg;
+ }
+}
diff --git a/sources/pyside2/tests/pysidetest/testobject.h b/sources/pyside2/tests/pysidetest/testobject.h
index 6cfb01101..f8a174d46 100644
--- a/sources/pyside2/tests/pysidetest/testobject.h
+++ b/sources/pyside2/tests/pysidetest/testobject.h
@@ -33,6 +33,7 @@
#include <QApplication>
#include <QMetaType>
#include <QVariant>
+#include <QDebug>
#ifdef pysidetest_EXPORTS
#define PYSIDE_EXPORTS 1
#endif
@@ -81,6 +82,7 @@ private:
int m_idValue;
QList<QObject*> m_children;
};
+PYSIDE_API QDebug operator<<(QDebug dbg, TestObject &testObject);
typedef int PySideInt;
@@ -104,6 +106,16 @@ signals:
void emitSignalWithNamespace(PySideCPP::TestObjectWithNamespace* obj);
void emitSignalWithTypedef(PySideInt val);
};
+PYSIDE_API QDebug operator<<(QDebug dbg, TestObjectWithNamespace &testObject);
+
+class PYSIDE_API TestObject2WithNamespace : public QObject
+{
+ Q_OBJECT
+public:
+ TestObject2WithNamespace(QObject* parent) : QObject(parent) {}
+ QString name() { return "TestObject2WithNamespace"; }
+};
+PYSIDE_API QDebug operator<<(QDebug dbg, TestObject2WithNamespace& testObject);
} // Namespace PySideCPP
diff --git a/sources/pyside2/tests/pysidetest/typesystem_pysidetest.xml b/sources/pyside2/tests/pysidetest/typesystem_pysidetest.xml
index 1904f236f..1e777edd2 100644
--- a/sources/pyside2/tests/pysidetest/typesystem_pysidetest.xml
+++ b/sources/pyside2/tests/pysidetest/typesystem_pysidetest.xml
@@ -37,6 +37,13 @@
<namespace-type name="PySideCPP">
<object-type name="TestObjectWithNamespace"/>
+ <object-type name="TestObject2WithNamespace">
+ <add-function signature="__repr__" return-type="PyObject*">
+ <inject-code class="target" position="beginning">
+ %PYARG_0 = Shiboken::String::fromCString("TestObject2WithNamespace(injected_repr)");
+ </inject-code>
+ </add-function>
+ </object-type>
</namespace-type>
<namespace-type name="PySideCPP2" generate="no">
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
index 5e9c63adc..ae3cdd86b 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
@@ -248,6 +248,15 @@ void AbstractMetaBuilderPrivate::registerHashFunction(const FunctionModelItem &f
}
}
+void AbstractMetaBuilderPrivate::registerToStringCapabilityIn(const NamespaceModelItem &nsItem)
+{
+ const FunctionList &streamOps = nsItem->findFunctions(QLatin1String("operator<<"));
+ for (const FunctionModelItem &item : streamOps)
+ registerToStringCapability(item, nullptr);
+ for (const NamespaceModelItem &ni : nsItem->namespaces())
+ registerToStringCapabilityIn(ni);
+}
+
/**
* Check if a class has a debug stream operator that can be used as toString
*/
@@ -261,7 +270,7 @@ void AbstractMetaBuilderPrivate::registerToStringCapability(const FunctionModelI
const ArgumentModelItem &arg = arguments.at(1);
if (AbstractMetaClass *cls = argumentToClass(arg, currentClass)) {
if (arg->type().indirections() < 2)
- cls->setToStringCapability(true);
+ cls->setToStringCapability(true, arg->type().indirections());
}
}
}
@@ -503,8 +512,12 @@ void AbstractMetaBuilderPrivate::traverseDom(const FileModelItem &dom)
ReportHandler::startProgress("Fixing class inheritance...");
for (AbstractMetaClass *cls : qAsConst(m_metaClasses)) {
- if (!cls->isInterface() && !cls->isNamespace())
+ if (!cls->isInterface() && !cls->isNamespace()) {
setupInheritance(cls);
+ if (!cls->hasVirtualDestructor() && cls->baseClass()
+ && cls->baseClass()->hasVirtualDestructor())
+ cls->setHasVirtualDestructor(true);
+ }
}
ReportHandler::startProgress("Detecting inconsistencies in class model...");
@@ -591,11 +604,7 @@ void AbstractMetaBuilderPrivate::traverseDom(const FileModelItem &dom)
registerHashFunction(item, nullptr);
}
- {
- const FunctionList &streamOps = dom->findFunctions(QLatin1String("operator<<"));
- for (const FunctionModelItem &item : streamOps)
- registerToStringCapability(item, nullptr);
- }
+ registerToStringCapabilityIn(dom);
{
FunctionList binaryOperators = dom->findFunctions(QStringLiteral("operator=="));
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h
index adf4d836b..30df236d6 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h
@@ -58,7 +58,7 @@ public:
void dumpLog() const;
AbstractMetaClassList classesTopologicalSorted(const AbstractMetaClassList &classList,
const Dependencies &additionalDependencies = Dependencies()) const;
- ScopeModelItem popScope() { return m_scopes.takeLast(); }
+ NamespaceModelItem popScope() { return m_scopes.takeLast(); }
void pushScope(const NamespaceModelItem &item);
@@ -108,6 +108,7 @@ public:
void checkFunctionModifications();
void registerHashFunction(const FunctionModelItem &functionItem,
AbstractMetaClass *currentClass);
+ void registerToStringCapabilityIn(const NamespaceModelItem &namespaceItem);
void registerToStringCapability(const FunctionModelItem &functionItem,
AbstractMetaClass *currentClass);
diff --git a/sources/shiboken2/ApiExtractor/abstractmetalang.h b/sources/shiboken2/ApiExtractor/abstractmetalang.h
index 6ed9dd36d..077191471 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetalang.h
+++ b/sources/shiboken2/ApiExtractor/abstractmetalang.h
@@ -1692,9 +1692,10 @@ public:
return m_stream;
}
- void setToStringCapability(bool value)
+ void setToStringCapability(bool value, uint indirections = 0)
{
m_hasToStringCapability = value;
+ m_toStringCapabilityIndirections = indirections;
}
bool hasToStringCapability() const
@@ -1702,6 +1703,11 @@ public:
return m_hasToStringCapability;
}
+ uint toStringCapabilityIndirections() const
+ {
+ return m_toStringCapabilityIndirections;
+ }
+
bool deleteInMainThread() const;
static AbstractMetaClass *findClass(const AbstractMetaClassList &classes,
@@ -1754,6 +1760,7 @@ private:
// FunctionModelItem m_qDebugStreamFunction;
bool m_stream = false;
+ uint m_toStringCapabilityIndirections = 0;
};
Q_DECLARE_OPERATORS_FOR_FLAGS(AbstractMetaClass::FunctionQueryOptions)
diff --git a/sources/shiboken2/ApiExtractor/tests/testdtorinformation.cpp b/sources/shiboken2/ApiExtractor/tests/testdtorinformation.cpp
index f4204e9b9..0eee8af24 100644
--- a/sources/shiboken2/ApiExtractor/tests/testdtorinformation.cpp
+++ b/sources/shiboken2/ApiExtractor/tests/testdtorinformation.cpp
@@ -69,6 +69,39 @@ void TestDtorInformation::testDtorIsVirtual()
QCOMPARE(AbstractMetaClass::findClass(classes, QLatin1String("Subject"))->hasVirtualDestructor(), true);
}
+void TestDtorInformation::testDtorFromBaseIsVirtual()
+{
+ const char* cppCode = R"CPP(class ControlBase { public: ~ControlBase() {} };
+class Control : public ControlBase {};
+class SubjectBase { public: virtual ~SubjectBase() {} };
+class Subject : public SubjectBase {};
+)CPP";
+ const char* xmlCode = R"XML(<typesystem package="Foo"><value-type name="ControlBase"/>
+<value-type name="Control"/>"
+<value-type name="SubjectBase"/>"
+<value-type name="Subject"/>
+</typesystem>
+)XML";
+ QScopedPointer<AbstractMetaBuilder> builder(TestUtil::parse(cppCode, xmlCode));
+ QVERIFY(!builder.isNull());
+ AbstractMetaClassList classes = builder->classes();
+ QCOMPARE(classes.count(), 4);
+
+ auto klass = AbstractMetaClass::findClass(classes, QLatin1String("ControlBase"));
+ QVERIFY(klass);
+ QVERIFY(!klass->hasVirtualDestructor());
+ klass = AbstractMetaClass::findClass(classes, QLatin1String("Control"));
+ QVERIFY(klass);
+ QVERIFY(!klass->hasVirtualDestructor());
+
+ klass = AbstractMetaClass::findClass(classes, QLatin1String("SubjectBase"));
+ QVERIFY(klass);
+ QVERIFY(klass->hasVirtualDestructor());
+ klass = AbstractMetaClass::findClass(classes, QLatin1String("Subject"));
+ QVERIFY(klass);
+ QVERIFY(klass->hasVirtualDestructor());
+}
+
void TestDtorInformation::testClassWithVirtualDtorIsPolymorphic()
{
const char* cppCode ="class Control { public: virtual ~Control() {} }; class Subject { protected: virtual ~Subject() {} };";
diff --git a/sources/shiboken2/ApiExtractor/tests/testdtorinformation.h b/sources/shiboken2/ApiExtractor/tests/testdtorinformation.h
index 068ef4952..0a57dd8d1 100644
--- a/sources/shiboken2/ApiExtractor/tests/testdtorinformation.h
+++ b/sources/shiboken2/ApiExtractor/tests/testdtorinformation.h
@@ -40,6 +40,7 @@ private slots:
void testDtorIsPrivate();
void testDtorIsProtected();
void testDtorIsVirtual();
+ void testDtorFromBaseIsVirtual();
void testClassWithVirtualDtorIsPolymorphic();
};
diff --git a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
index 3b6d1c870..86abf21b0 100644
--- a/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
+++ b/sources/shiboken2/generator/qtdoc/qtdocgenerator.cpp
@@ -1236,10 +1236,6 @@ void QtXmlToSphinx::handlePageTag(QXmlStreamReader &reader)
: writeEscapedRstText(m_output, fullTitle);
m_output << endl << Pad('*', size) << endl << endl;
-
- const QStringRef brief = reader.attributes().value(briefAttribute());
- if (!brief.isEmpty())
- m_output << escape(brief) << endl << endl;
}
void QtXmlToSphinx::handleTargetTag(QXmlStreamReader &reader)
@@ -1625,7 +1621,7 @@ void QtDocGenerator::generateClass(QTextStream &s, GeneratorContext &classContex
m_docParser->setPackageName(metaClass->package());
m_docParser->fillDocumentation(const_cast<AbstractMetaClass*>(metaClass));
- s << ".. module:: " << metaClass->package() << endl;
+ s << ".. currentmodule:: " << metaClass->package() << endl;
QString className = getClassTargetFullName(metaClass, false);
s << ".. _" << className << ":" << endl << endl;
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index 146a53d2d..5460fd7c7 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -3941,9 +3941,10 @@ void CppGenerator::writeClassDefinition(QTextStream &s,
m_tpFuncs[func->name()] = cpythonFunctionName(func);
}
if (m_tpFuncs.value(QLatin1String("__repr__")).isEmpty()
- && !metaClass->isQObject()
&& metaClass->hasToStringCapability()) {
- m_tpFuncs[QLatin1String("__repr__")] = writeReprFunction(s, classContext);
+ m_tpFuncs[QLatin1String("__repr__")] = writeReprFunction(s,
+ classContext,
+ metaClass->toStringCapabilityIndirections());
}
// class or some ancestor has multiple inheritance
@@ -5999,7 +6000,9 @@ void CppGenerator::writeIndexError(QTextStream &s, const QString &errorMsg)
s << INDENT << '}' << endl;
}
-QString CppGenerator::writeReprFunction(QTextStream &s, GeneratorContext &context)
+QString CppGenerator::writeReprFunction(QTextStream &s,
+ GeneratorContext &context,
+ uint indirections)
{
const AbstractMetaClass *metaClass = context.metaClass();
QString funcName = cpythonBaseName(metaClass) + QLatin1String("__repr__");
@@ -6012,7 +6015,7 @@ QString CppGenerator::writeReprFunction(QTextStream &s, GeneratorContext &contex
s << INDENT << "buffer.open(QBuffer::ReadWrite);" << endl;
s << INDENT << "QDebug dbg(&buffer);" << endl;
s << INDENT << "dbg << ";
- if (metaClass->typeEntry()->isValue())
+ if (metaClass->typeEntry()->isValue() || indirections == 0)
s << '*';
s << CPP_SELF_VAR << ';' << endl;
s << INDENT << "buffer.close();" << endl;
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.h b/sources/shiboken2/generator/shiboken2/cppgenerator.h
index ae6da9582..005518f96 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.h
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.h
@@ -336,7 +336,7 @@ private:
/// Helper function for writeStdListWrapperMethods.
void writeIndexError(QTextStream &s, const QString &errorMsg);
- QString writeReprFunction(QTextStream &s, GeneratorContext &context);
+ QString writeReprFunction(QTextStream &s, GeneratorContext &context, uint indirections);
const AbstractMetaFunction *boolCast(const AbstractMetaClass *metaClass) const;
bool hasBoolCast(const AbstractMetaClass *metaClass) const
diff --git a/sources/shiboken2/libshiboken/shibokenbuffer.cpp b/sources/shiboken2/libshiboken/shibokenbuffer.cpp
index 330470183..dd6e46320 100644
--- a/sources/shiboken2/libshiboken/shibokenbuffer.cpp
+++ b/sources/shiboken2/libshiboken/shibokenbuffer.cpp
@@ -43,7 +43,11 @@
bool Shiboken::Buffer::checkType(PyObject *pyObj)
{
+#ifdef IS_PY3K
+ return PyObject_CheckBuffer(pyObj) != 0;
+#else
return PyObject_CheckReadBuffer(pyObj) != 0;
+#endif
}
void *Shiboken::Buffer::getPointer(PyObject *pyObj, Py_ssize_t *size)