aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2018-06-07 11:17:32 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2018-06-07 11:17:37 +0200
commit60a3b6a16304af4b1d8896a06b8407fe49f80ed2 (patch)
tree6dca986c5e439c7cb39b17643129dadb436d2fea
parent33943b54e9470dc8830e94270e6521524acb2954 (diff)
parent823eea34b77ca16a545a75b55619a5ed4da38c0e (diff)
Merge branch '5.9' into 5.11
-rw-r--r--build_scripts/main.py3
-rw-r--r--build_scripts/wheel_override.py2
-rw-r--r--examples/3d/simple3d.py2
-rw-r--r--examples/scriptableapplication/pythonutils.cpp27
-rw-r--r--examples/webenginewidgets/tabbedbrowser/bookmarkwidget.py1
-rw-r--r--examples/webenginewidgets/tabbedbrowser/browsertabwidget.py1
-rw-r--r--examples/webenginewidgets/tabbedbrowser/downloadwidget.py2
-rw-r--r--examples/webenginewidgets/tabbedbrowser/main.py6
-rwxr-xr-xexamples/widgets/animation/animatedtiles/animatedtiles.py2
-rwxr-xr-xexamples/widgets/animation/appchooser/appchooser.py2
-rw-r--r--examples/widgets/animation/easing/easing.py2
-rwxr-xr-xexamples/widgets/animation/states/states.py120
-rwxr-xr-xexamples/widgets/draganddrop/draggabletext/draggabletext.py2
-rw-r--r--examples/widgets/richtext/syntaxhighlighter/syntaxhighlighter.py2
-rwxr-xr-xexamples/xmlpatterns/schema/schema.py2
m---------sources/pyside2-tools0
-rw-r--r--sources/pyside2/PySide2/QtCore/typesystem_core_common.xml147
-rw-r--r--sources/pyside2/PySide2/QtQml/typesystem_qml.xml5
-rw-r--r--sources/pyside2/PySide2/support/signature/mapping.py1
-rw-r--r--sources/pyside2/doc/conf.py.in6
-rw-r--r--sources/pyside2/doc/gettingstarted.rst2
-rw-r--r--sources/pyside2/doc/index.rst4
-rw-r--r--sources/pyside2/doc/qtmodules/pyside-qtwebenginecore.qdocconf.in3
-rw-r--r--sources/pyside2/doc/qtmodules/pyside-qtwebenginewidgets.qdocconf.in3
-rw-r--r--sources/pyside2/doc/tutorials/examples/images/tabbedbrowser.pngbin0 -> 51262 bytes
-rw-r--r--sources/pyside2/doc/tutorials/examples/tabbedbrowser.rst57
-rw-r--r--sources/pyside2/doc/tutorials/index.rst21
-rw-r--r--sources/pyside2/tests/QtCore/bug_938.py3
-rw-r--r--sources/pyside2/tests/QtCore/deepcopy_test.py3
-rw-r--r--sources/pyside2/tests/QtCore/qbytearray_concatenation_operator_test.py31
-rw-r--r--sources/pyside2/tests/QtCore/qbytearray_operator_iadd_test.py23
-rw-r--r--sources/pyside2/tests/QtCore/qbytearray_operator_test.py29
-rw-r--r--sources/pyside2/tests/QtCore/qbytearray_test.py100
-rw-r--r--sources/pyside2/tests/QtCore/qdatastream_test.py48
-rw-r--r--sources/pyside2/tests/QtCore/qfile_test.py2
-rw-r--r--sources/pyside2/tests/QtCore/qfileread_test.py5
-rw-r--r--sources/pyside2/tests/QtCore/qmessageauthenticationcode_test.py3
-rw-r--r--sources/pyside2/tests/QtCore/qtextstream_test.py12
-rw-r--r--sources/pyside2/tests/QtCore/qtimezone_test.py3
-rw-r--r--sources/pyside2/tests/QtCore/repr_test.py3
-rw-r--r--sources/pyside2/tests/QtCore/unicode_test.py1
-rw-r--r--sources/pyside2/tests/QtGui/bug_660.py2
-rw-r--r--sources/pyside2/tests/QtGui/qtextdocumentwriter_test.py3
-rw-r--r--sources/pyside2/tests/QtNetwork/bug_1084.py2
-rw-r--r--sources/pyside2/tests/QtNetwork/bug_446.py5
-rw-r--r--sources/pyside2/tests/QtNetwork/udpsocket_test.py3
-rw-r--r--sources/pyside2/tests/QtOpenGL/qglbuffer_test.py2
-rw-r--r--sources/pyside2/tests/QtWebEngineCore/web_engine_custom_scheme.py7
-rw-r--r--sources/pyside2/tests/QtXml/qdomdocument_test.py10
-rw-r--r--sources/pyside2/tests/QtXmlPatterns/import_test.py5
-rw-r--r--sources/pyside2/tests/registry/exists_darwin_5_6_4_ci.py2
-rw-r--r--sources/pyside2/tests/registry/exists_darwin_5_9_4_ci.py2
-rw-r--r--sources/pyside2/tests/registry/exists_linux_5_6_4_ci.py2
-rw-r--r--sources/pyside2/tests/registry/exists_linux_5_9_4_ci.py2
-rw-r--r--sources/pyside2/tests/registry/exists_win32_5_6_4_ci.py2
-rw-r--r--sources/pyside2/tests/registry/exists_win32_5_9_4_ci.py2
-rw-r--r--sources/pyside2/tests/support/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/support/voidptr_test.py47
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp100
-rw-r--r--sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h5
-rw-r--r--sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp23
-rw-r--r--sources/shiboken2/ApiExtractor/parser/codemodel.cpp14
-rw-r--r--sources/shiboken2/ApiExtractor/parser/codemodel.h3
-rw-r--r--sources/shiboken2/ApiExtractor/typeparser.cpp126
-rw-r--r--sources/shiboken2/ApiExtractor/typeparser.h25
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp6
-rw-r--r--sources/shiboken2/libshiboken/basewrapper.cpp2
-rw-r--r--sources/shiboken2/libshiboken/pep384impl.cpp2
-rw-r--r--sources/shiboken2/libshiboken/pep384impl.h2
-rw-r--r--sources/shiboken2/libshiboken/sbkpython.h1
-rw-r--r--sources/shiboken2/libshiboken/sbkstring.cpp10
-rw-r--r--sources/shiboken2/libshiboken/sbkstring.h4
-rw-r--r--sources/shiboken2/libshiboken/voidptr.cpp9
73 files changed, 654 insertions, 468 deletions
diff --git a/build_scripts/main.py b/build_scripts/main.py
index f288756c1..dca373401 100644
--- a/build_scripts/main.py
+++ b/build_scripts/main.py
@@ -499,6 +499,9 @@ class PysideBuild(_build):
log.info("nmake was found in {}".format(nmake_path))
make_name = "nmake"
make_generator = "NMake Makefiles"
+ if OPTION_JOBS:
+ msg = "Option --jobs can only be used with 'jom' on Windows."
+ raise DistutilsSetupError(msg)
elif OPTION_MAKESPEC == "mingw":
make_name = "mingw32-make"
make_generator = "MinGW Makefiles"
diff --git a/build_scripts/wheel_override.py b/build_scripts/wheel_override.py
index ee8bd8382..f6eaedf1c 100644
--- a/build_scripts/wheel_override.py
+++ b/build_scripts/wheel_override.py
@@ -195,6 +195,6 @@ if wheel_module_exists:
# create a properly named package.
limited_api_enabled = OPTION_LIMITED_API and sys.version_info[0] >= 3
if limited_api_enabled:
- self.py_limited_api = "cp35.cp36.cp37.cp38"
+ self.py_limited_api = "cp35.cp36"
_bdist_wheel.finalize_options(self)
diff --git a/examples/3d/simple3d.py b/examples/3d/simple3d.py
index 3cfa39a05..e4b06132b 100644
--- a/examples/3d/simple3d.py
+++ b/examples/3d/simple3d.py
@@ -146,7 +146,7 @@ class Window(Qt3DExtras.Qt3DWindow):
self.sphereRotateTransformAnimation = QPropertyAnimation(self.sphereTransform)
self.sphereRotateTransformAnimation.setTargetObject(self.controller)
- self.sphereRotateTransformAnimation.setPropertyName("angle")
+ self.sphereRotateTransformAnimation.setPropertyName(b"angle")
self.sphereRotateTransformAnimation.setStartValue(0)
self.sphereRotateTransformAnimation.setEndValue(360)
self.sphereRotateTransformAnimation.setDuration(10000)
diff --git a/examples/scriptableapplication/pythonutils.cpp b/examples/scriptableapplication/pythonutils.cpp
index 2f7d2c2ad..f546a5a6c 100644
--- a/examples/scriptableapplication/pythonutils.cpp
+++ b/examples/scriptableapplication/pythonutils.cpp
@@ -54,6 +54,8 @@
#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
#include <QtCore/QStringList>
+#include <QtCore/QTemporaryFile>
+#include <QtCore/QDir>
#include <sbkpython.h>
#include <sbkconverter.h>
@@ -122,7 +124,7 @@ bool bindAppObject(const QString &moduleName, const QString &name,
return false;
PyTypeObject *typeObject = SbkAppLibTypes[index];
- PyObject *po = Shiboken::Conversions::pointerToPython(reinterpret_cast<const SbkObjectType *>(typeObject), o);
+ PyObject *po = Shiboken::Conversions::pointerToPython(reinterpret_cast<SbkObjectType *>(typeObject), o);
if (!po) {
qWarning() << __FUNCTION__ << "Failed to create wrapper for" << o;
return false;
@@ -152,17 +154,22 @@ bool runScript(const QStringList &script)
{
if (init() == PythonUninitialized)
return false;
+
+ // Concatenating all the lines
+ QString content;
+ QTextStream ss(&content);
+ for (const QString &line: script)
+ ss << line << "\n";
+
+ // Executing the whole script as one line
bool result = true;
- for (const QString& lineS : script) {
- const QByteArray line = lineS.toUtf8();
- if (PyRun_SimpleString(line.constData()) == -1) {
- if (PyErr_Occurred())
- PyErr_Print();
- qWarning() << __FUNCTION__ << "Error at" << line;
- result = false;
- break;
- }
+ const QByteArray line = content.toUtf8();
+ if (PyRun_SimpleString(line.constData()) == -1) {
+ if (PyErr_Occurred())
+ PyErr_Print();
+ result = false;
}
+
return result;
}
diff --git a/examples/webenginewidgets/tabbedbrowser/bookmarkwidget.py b/examples/webenginewidgets/tabbedbrowser/bookmarkwidget.py
index 01a69b921..6bd2b4586 100644
--- a/examples/webenginewidgets/tabbedbrowser/bookmarkwidget.py
+++ b/examples/webenginewidgets/tabbedbrowser/bookmarkwidget.py
@@ -122,6 +122,7 @@ def _serialize_model(model, directory):
# Bookmarks as a tree view to be used in a dock widget with
# functionality to persist and populate tool bars and menus.
class BookmarkWidget(QTreeView):
+ """Provides a tree view to manage the bookmarks."""
open_bookmark = QtCore.Signal(QUrl)
open_bookmark_in_new_tab = QtCore.Signal(QUrl)
diff --git a/examples/webenginewidgets/tabbedbrowser/browsertabwidget.py b/examples/webenginewidgets/tabbedbrowser/browsertabwidget.py
index d9263be08..d85b8ad3d 100644
--- a/examples/webenginewidgets/tabbedbrowser/browsertabwidget.py
+++ b/examples/webenginewidgets/tabbedbrowser/browsertabwidget.py
@@ -50,6 +50,7 @@ from PySide2.QtWebEngineWidgets import (QWebEngineDownloadItem,
QWebEnginePage, QWebEngineProfile)
class BrowserTabWidget(QTabWidget):
+ """Enables having several tabs with QWebEngineView."""
url_changed = QtCore.Signal(QUrl)
enabled_changed = QtCore.Signal(QWebEnginePage.WebAction, bool)
diff --git a/examples/webenginewidgets/tabbedbrowser/downloadwidget.py b/examples/webenginewidgets/tabbedbrowser/downloadwidget.py
index 030dfc14b..437c534ec 100644
--- a/examples/webenginewidgets/tabbedbrowser/downloadwidget.py
+++ b/examples/webenginewidgets/tabbedbrowser/downloadwidget.py
@@ -48,7 +48,7 @@ from PySide2.QtWebEngineWidgets import QWebEngineDownloadItem
# A QProgressBar with context menu for displaying downloads in a QStatusBar.
class DownloadWidget(QProgressBar):
-
+ """Lets you track progress of a QWebEngineDownloadItem."""
finished = QtCore.Signal()
remove_requested = QtCore.Signal()
diff --git a/examples/webenginewidgets/tabbedbrowser/main.py b/examples/webenginewidgets/tabbedbrowser/main.py
index 12efdcd5c..09b6cc9ec 100644
--- a/examples/webenginewidgets/tabbedbrowser/main.py
+++ b/examples/webenginewidgets/tabbedbrowser/main.py
@@ -60,6 +60,7 @@ from PySide2.QtWebEngineWidgets import (QWebEngineDownloadItem, QWebEnginePage,
main_windows = []
def create_main_window():
+ """Creates a MainWindow using 75% of the available screen resolution."""
main_win = MainWindow()
main_windows.append(main_win)
available_geometry = app.desktop().availableGeometry(main_win)
@@ -68,11 +69,14 @@ def create_main_window():
return main_win
def create_main_window_with_browser():
+ """Creates a MainWindow with a tab that loads the www.qt.io webpage."""
main_win = create_main_window()
return main_win.add_browser_tab()
class MainWindow(QMainWindow):
-
+ """Provides the parent window that includes the BookmarkWidget,
+ BrowserTabWidget, and a DownloadWidget, to offer the complete
+ web browsing experience."""
def __init__(self):
super(MainWindow, self).__init__()
diff --git a/examples/widgets/animation/animatedtiles/animatedtiles.py b/examples/widgets/animation/animatedtiles/animatedtiles.py
index f50c99378..e390cfcee 100755
--- a/examples/widgets/animation/animatedtiles/animatedtiles.py
+++ b/examples/widgets/animation/animatedtiles/animatedtiles.py
@@ -229,7 +229,7 @@ if __name__ == '__main__':
group = QtCore.QParallelAnimationGroup()
for i, item in enumerate(items):
- anim = QtCore.QPropertyAnimation(item, 'pos')
+ anim = QtCore.QPropertyAnimation(item, b'pos')
anim.setDuration(750 + i * 25)
anim.setEasingCurve(QtCore.QEasingCurve.InOutBack)
group.addAnimation(anim)
diff --git a/examples/widgets/animation/appchooser/appchooser.py b/examples/widgets/animation/appchooser/appchooser.py
index 67550ab4e..862e2bef4 100755
--- a/examples/widgets/animation/appchooser/appchooser.py
+++ b/examples/widgets/animation/appchooser/appchooser.py
@@ -79,7 +79,7 @@ def createStates(objects, selectedRect, parent):
def createAnimations(objects, machine):
for obj in objects:
- animation = QtCore.QPropertyAnimation(obj, 'geometry', obj)
+ animation = QtCore.QPropertyAnimation(obj, b'geometry', obj)
machine.addDefaultAnimation(animation)
diff --git a/examples/widgets/animation/easing/easing.py b/examples/widgets/animation/easing/easing.py
index 17377e83d..6a37d46d8 100644
--- a/examples/widgets/animation/easing/easing.py
+++ b/examples/widgets/animation/easing/easing.py
@@ -135,7 +135,7 @@ class Window(QtWidgets.QWidget):
self.m_scene.addItem(self.m_item.pixmap_item)
self.m_ui.graphicsView.setScene(self.m_scene)
- self.m_anim = Animation(self.m_item, 'pos')
+ self.m_anim = Animation(self.m_item, b'pos')
self.m_anim.setEasingCurve(QtCore.QEasingCurve.OutBounce)
self.m_ui.easingCurvePicker.setCurrentRow(int(QtCore.QEasingCurve.OutBounce))
diff --git a/examples/widgets/animation/states/states.py b/examples/widgets/animation/states/states.py
index 6b31922cb..6cf1597dd 100755
--- a/examples/widgets/animation/states/states.py
+++ b/examples/widgets/animation/states/states.py
@@ -191,71 +191,71 @@ if __name__ == '__main__':
t1 = state1.addTransition(button.clicked, state2)
animation1SubGroup = QtCore.QSequentialAnimationGroup()
animation1SubGroup.addPause(250)
- animation1SubGroup.addAnimation(QtCore.QPropertyAnimation(box, 'geometry', state1))
+ animation1SubGroup.addAnimation(QtCore.QPropertyAnimation(box, b'geometry', state1))
t1.addAnimation(animation1SubGroup)
- t1.addAnimation(QtCore.QPropertyAnimation(widget, 'geometry', state1))
- t1.addAnimation(QtCore.QPropertyAnimation(p1, 'pos', state1))
- t1.addAnimation(QtCore.QPropertyAnimation(p2, 'pos', state1))
- t1.addAnimation(QtCore.QPropertyAnimation(p3, 'pos', state1))
- t1.addAnimation(QtCore.QPropertyAnimation(p4, 'pos', state1))
- t1.addAnimation(QtCore.QPropertyAnimation(p5, 'pos', state1))
- t1.addAnimation(QtCore.QPropertyAnimation(p6, 'pos', state1))
- t1.addAnimation(QtCore.QPropertyAnimation(p1, 'rotation', state1))
- t1.addAnimation(QtCore.QPropertyAnimation(p2, 'rotation', state1))
- t1.addAnimation(QtCore.QPropertyAnimation(p3, 'rotation', state1))
- t1.addAnimation(QtCore.QPropertyAnimation(p4, 'rotation', state1))
- t1.addAnimation(QtCore.QPropertyAnimation(p5, 'rotation', state1))
- t1.addAnimation(QtCore.QPropertyAnimation(p6, 'rotation', state1))
- t1.addAnimation(QtCore.QPropertyAnimation(p1, 'opacity', state1))
- t1.addAnimation(QtCore.QPropertyAnimation(p2, 'opacity', state1))
- t1.addAnimation(QtCore.QPropertyAnimation(p3, 'opacity', state1))
- t1.addAnimation(QtCore.QPropertyAnimation(p4, 'opacity', state1))
- t1.addAnimation(QtCore.QPropertyAnimation(p5, 'opacity', state1))
- t1.addAnimation(QtCore.QPropertyAnimation(p6, 'opacity', state1))
+ t1.addAnimation(QtCore.QPropertyAnimation(widget, b'geometry', state1))
+ t1.addAnimation(QtCore.QPropertyAnimation(p1, b'pos', state1))
+ t1.addAnimation(QtCore.QPropertyAnimation(p2, b'pos', state1))
+ t1.addAnimation(QtCore.QPropertyAnimation(p3, b'pos', state1))
+ t1.addAnimation(QtCore.QPropertyAnimation(p4, b'pos', state1))
+ t1.addAnimation(QtCore.QPropertyAnimation(p5, b'pos', state1))
+ t1.addAnimation(QtCore.QPropertyAnimation(p6, b'pos', state1))
+ t1.addAnimation(QtCore.QPropertyAnimation(p1, b'rotation', state1))
+ t1.addAnimation(QtCore.QPropertyAnimation(p2, b'rotation', state1))
+ t1.addAnimation(QtCore.QPropertyAnimation(p3, b'rotation', state1))
+ t1.addAnimation(QtCore.QPropertyAnimation(p4, b'rotation', state1))
+ t1.addAnimation(QtCore.QPropertyAnimation(p5, b'rotation', state1))
+ t1.addAnimation(QtCore.QPropertyAnimation(p6, b'rotation', state1))
+ t1.addAnimation(QtCore.QPropertyAnimation(p1, b'opacity', state1))
+ t1.addAnimation(QtCore.QPropertyAnimation(p2, b'opacity', state1))
+ t1.addAnimation(QtCore.QPropertyAnimation(p3, b'opacity', state1))
+ t1.addAnimation(QtCore.QPropertyAnimation(p4, b'opacity', state1))
+ t1.addAnimation(QtCore.QPropertyAnimation(p5, b'opacity', state1))
+ t1.addAnimation(QtCore.QPropertyAnimation(p6, b'opacity', state1))
t2 = state2.addTransition(button.clicked, state3)
- t2.addAnimation(QtCore.QPropertyAnimation(box, 'geometry', state2))
- t2.addAnimation(QtCore.QPropertyAnimation(widget, 'geometry', state2))
- t2.addAnimation(QtCore.QPropertyAnimation(p1, 'pos', state2))
- t2.addAnimation(QtCore.QPropertyAnimation(p2, 'pos', state2))
- t2.addAnimation(QtCore.QPropertyAnimation(p3, 'pos', state2))
- t2.addAnimation(QtCore.QPropertyAnimation(p4, 'pos', state2))
- t2.addAnimation(QtCore.QPropertyAnimation(p5, 'pos', state2))
- t2.addAnimation(QtCore.QPropertyAnimation(p6, 'pos', state2))
- t2.addAnimation(QtCore.QPropertyAnimation(p1, 'rotation', state2))
- t2.addAnimation(QtCore.QPropertyAnimation(p2, 'rotation', state2))
- t2.addAnimation(QtCore.QPropertyAnimation(p3, 'rotation', state2))
- t2.addAnimation(QtCore.QPropertyAnimation(p4, 'rotation', state2))
- t2.addAnimation(QtCore.QPropertyAnimation(p5, 'rotation', state2))
- t2.addAnimation(QtCore.QPropertyAnimation(p6, 'rotation', state2))
- t2.addAnimation(QtCore.QPropertyAnimation(p1, 'opacity', state2))
- t2.addAnimation(QtCore.QPropertyAnimation(p2, 'opacity', state2))
- t2.addAnimation(QtCore.QPropertyAnimation(p3, 'opacity', state2))
- t2.addAnimation(QtCore.QPropertyAnimation(p4, 'opacity', state2))
- t2.addAnimation(QtCore.QPropertyAnimation(p5, 'opacity', state2))
- t2.addAnimation(QtCore.QPropertyAnimation(p6, 'opacity', state2))
+ t2.addAnimation(QtCore.QPropertyAnimation(box, b'geometry', state2))
+ t2.addAnimation(QtCore.QPropertyAnimation(widget, b'geometry', state2))
+ t2.addAnimation(QtCore.QPropertyAnimation(p1, b'pos', state2))
+ t2.addAnimation(QtCore.QPropertyAnimation(p2, b'pos', state2))
+ t2.addAnimation(QtCore.QPropertyAnimation(p3, b'pos', state2))
+ t2.addAnimation(QtCore.QPropertyAnimation(p4, b'pos', state2))
+ t2.addAnimation(QtCore.QPropertyAnimation(p5, b'pos', state2))
+ t2.addAnimation(QtCore.QPropertyAnimation(p6, b'pos', state2))
+ t2.addAnimation(QtCore.QPropertyAnimation(p1, b'rotation', state2))
+ t2.addAnimation(QtCore.QPropertyAnimation(p2, b'rotation', state2))
+ t2.addAnimation(QtCore.QPropertyAnimation(p3, b'rotation', state2))
+ t2.addAnimation(QtCore.QPropertyAnimation(p4, b'rotation', state2))
+ t2.addAnimation(QtCore.QPropertyAnimation(p5, b'rotation', state2))
+ t2.addAnimation(QtCore.QPropertyAnimation(p6, b'rotation', state2))
+ t2.addAnimation(QtCore.QPropertyAnimation(p1, b'opacity', state2))
+ t2.addAnimation(QtCore.QPropertyAnimation(p2, b'opacity', state2))
+ t2.addAnimation(QtCore.QPropertyAnimation(p3, b'opacity', state2))
+ t2.addAnimation(QtCore.QPropertyAnimation(p4, b'opacity', state2))
+ t2.addAnimation(QtCore.QPropertyAnimation(p5, b'opacity', state2))
+ t2.addAnimation(QtCore.QPropertyAnimation(p6, b'opacity', state2))
t3 = state3.addTransition(button.clicked, state1)
- t3.addAnimation(QtCore.QPropertyAnimation(box, 'geometry', state3))
- t3.addAnimation(QtCore.QPropertyAnimation(widget, 'geometry', state3))
- t3.addAnimation(QtCore.QPropertyAnimation(p1, 'pos', state3))
- t3.addAnimation(QtCore.QPropertyAnimation(p2, 'pos', state3))
- t3.addAnimation(QtCore.QPropertyAnimation(p3, 'pos', state3))
- t3.addAnimation(QtCore.QPropertyAnimation(p4, 'pos', state3))
- t3.addAnimation(QtCore.QPropertyAnimation(p5, 'pos', state3))
- t3.addAnimation(QtCore.QPropertyAnimation(p6, 'pos', state3))
- t3.addAnimation(QtCore.QPropertyAnimation(p1, 'rotation', state3))
- t3.addAnimation(QtCore.QPropertyAnimation(p2, 'rotation', state3))
- t3.addAnimation(QtCore.QPropertyAnimation(p3, 'rotation', state3))
- t3.addAnimation(QtCore.QPropertyAnimation(p4, 'rotation', state3))
- t3.addAnimation(QtCore.QPropertyAnimation(p5, 'rotation', state3))
- t3.addAnimation(QtCore.QPropertyAnimation(p6, 'rotation', state3))
- t3.addAnimation(QtCore.QPropertyAnimation(p1, 'opacity', state3))
- t3.addAnimation(QtCore.QPropertyAnimation(p2, 'opacity', state3))
- t3.addAnimation(QtCore.QPropertyAnimation(p3, 'opacity', state3))
- t3.addAnimation(QtCore.QPropertyAnimation(p4, 'opacity', state3))
- t3.addAnimation(QtCore.QPropertyAnimation(p5, 'opacity', state3))
- t3.addAnimation(QtCore.QPropertyAnimation(p6, 'opacity', state3))
+ t3.addAnimation(QtCore.QPropertyAnimation(box, b'geometry', state3))
+ t3.addAnimation(QtCore.QPropertyAnimation(widget, b'geometry', state3))
+ t3.addAnimation(QtCore.QPropertyAnimation(p1, b'pos', state3))
+ t3.addAnimation(QtCore.QPropertyAnimation(p2, b'pos', state3))
+ t3.addAnimation(QtCore.QPropertyAnimation(p3, b'pos', state3))
+ t3.addAnimation(QtCore.QPropertyAnimation(p4, b'pos', state3))
+ t3.addAnimation(QtCore.QPropertyAnimation(p5, b'pos', state3))
+ t3.addAnimation(QtCore.QPropertyAnimation(p6, b'pos', state3))
+ t3.addAnimation(QtCore.QPropertyAnimation(p1, b'rotation', state3))
+ t3.addAnimation(QtCore.QPropertyAnimation(p2, b'rotation', state3))
+ t3.addAnimation(QtCore.QPropertyAnimation(p3, b'rotation', state3))
+ t3.addAnimation(QtCore.QPropertyAnimation(p4, b'rotation', state3))
+ t3.addAnimation(QtCore.QPropertyAnimation(p5, b'rotation', state3))
+ t3.addAnimation(QtCore.QPropertyAnimation(p6, b'rotation', state3))
+ t3.addAnimation(QtCore.QPropertyAnimation(p1, b'opacity', state3))
+ t3.addAnimation(QtCore.QPropertyAnimation(p2, b'opacity', state3))
+ t3.addAnimation(QtCore.QPropertyAnimation(p3, b'opacity', state3))
+ t3.addAnimation(QtCore.QPropertyAnimation(p4, b'opacity', state3))
+ t3.addAnimation(QtCore.QPropertyAnimation(p5, b'opacity', state3))
+ t3.addAnimation(QtCore.QPropertyAnimation(p6, b'opacity', state3))
machine.start()
diff --git a/examples/widgets/draganddrop/draggabletext/draggabletext.py b/examples/widgets/draganddrop/draggabletext/draggabletext.py
index 67e988714..d2bcdf5ae 100755
--- a/examples/widgets/draganddrop/draggabletext/draggabletext.py
+++ b/examples/widgets/draganddrop/draggabletext/draggabletext.py
@@ -64,7 +64,7 @@ class DragLabel(QLabel):
mimeData = QMimeData()
mimeData.setText(self.text())
mimeData.setData('application/x-hotspot',
- '%d %d' % (hotSpot.x(), hotSpot.y()))
+ b'%d %d' % (hotSpot.x(), hotSpot.y()))
pixmap = QPixmap(self.size())
self.render(pixmap)
diff --git a/examples/widgets/richtext/syntaxhighlighter/syntaxhighlighter.py b/examples/widgets/richtext/syntaxhighlighter/syntaxhighlighter.py
index 841943292..32adb70c7 100644
--- a/examples/widgets/richtext/syntaxhighlighter/syntaxhighlighter.py
+++ b/examples/widgets/richtext/syntaxhighlighter/syntaxhighlighter.py
@@ -75,7 +75,7 @@ class MainWindow(QtWidgets.QMainWindow):
if fileName!="":
inFile = QtCore.QFile(fileName)
if inFile.open(QtCore.QFile.ReadOnly | QtCore.QFile.Text):
- self.editor.setPlainText(unicode(inFile.readAll()))
+ self.editor.setPlainText(str(inFile.readAll()))
def setupEditor(self):
variableFormat = QtGui.QTextCharFormat()
diff --git a/examples/xmlpatterns/schema/schema.py b/examples/xmlpatterns/schema/schema.py
index a10cc32ce..4a24e4f30 100755
--- a/examples/xmlpatterns/schema/schema.py
+++ b/examples/xmlpatterns/schema/schema.py
@@ -61,7 +61,7 @@ except NameError:
# Python v3.
def encode_utf8(ba):
- return str(ba, encoding='utf8')
+ return str(ba.data(), encoding='utf8')
def decode_utf8(qs):
return QtCore.QByteArray(bytes(qs, encoding='utf8'))
diff --git a/sources/pyside2-tools b/sources/pyside2-tools
-Subproject 413ecc73fbe6d6717ae2132e86648ac8b6da9d3
+Subproject b32eedc27f61d2ce4a8eed61b5adc2b75ce703b
diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml
index ed577b098..47d43f2eb 100644
--- a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml
+++ b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml
@@ -44,6 +44,7 @@
<custom-type name="str" />
<custom-type name="PyBytes" />
+ <custom-type name="PyByteArray" />
<custom-type name="PyCallable" />
<custom-type name="PyObject" />
<custom-type name="PySequence" />
@@ -2501,14 +2502,16 @@
<add-conversion type="Py_None">
%out = %OUTTYPE();
</add-conversion>
- <add-conversion type="PyString" check="Shiboken::String::check(%in)">
- %out = %OUTTYPE(Shiboken::String::toCString(%in), Shiboken::String::len(%in));
- </add-conversion>
<add-conversion type="PyBytes">
#ifdef IS_PY3K
%out = %OUTTYPE(PyBytes_AS_STRING(%in), PyBytes_GET_SIZE(%in));
+ #else
+ %out = %OUTTYPE(Shiboken::String::toCString(%in), Shiboken::String::len(%in));
#endif
</add-conversion>
+ <add-conversion type="PyString" check="Shiboken::String::check(%in) &amp;&amp; !PyUnicode_Check(%in)">
+ %out = %OUTTYPE(Shiboken::String::toCString(%in), Shiboken::String::len(%in));
+ </add-conversion>
</target-to-native>
</conversion-rule>
@@ -2569,47 +2572,108 @@
<modify-function signature="operator+(QByteArray,const char*)" remove="all" />
<modify-function signature="operator+(QString,QByteArray)" remove="all" />
<modify-function signature="operator+(QByteArray,QString)" remove="all" />
- <add-function signature="operator+(PyUnicode)">
+ <add-function signature="operator+(PyBytes,QByteArray)">
<inject-code>
- Shiboken::AutoDecRef str(PyUnicode_AsASCIIString(%PYARG_1));
- if (!str.isNull()) {
- QByteArray b(PyBytes_AS_STRING(str.object()), PyBytes_GET_SIZE (str.object()));
- b.prepend(*%CPPSELF);
- %PYARG_0 = %CONVERTTOPYTHON[QByteArray](b);
- }
+ QByteArray ba = QByteArray(PyBytes_AS_STRING(%PYARG_1), PyBytes_GET_SIZE(%PYARG_1)) + *%CPPSELF;
+ %PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba);
</inject-code>
</add-function>
- <add-function signature="operator+(PyUnicode,QByteArray)">
+ <add-function signature="operator+(PyByteArray, QByteArray)" return-type="QByteArray">
<inject-code>
- Shiboken::AutoDecRef str(PyUnicode_AsASCIIString(%PYARG_1));
- if (!str.isNull()) {
- QByteArray b(PyBytes_AS_STRING(str.object()), PyBytes_GET_SIZE(str.object()));
- b.append(*%CPPSELF);
- %PYARG_0 = %CONVERTTOPYTHON[QByteArray](b);
- }
+ QByteArray ba = QByteArray(PyByteArray_AsString(%PYARG_1), PyByteArray_Size(%PYARG_1)) + *%CPPSELF;
+ %PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba);
</inject-code>
</add-function>
- <add-function signature="operator+(PyBytes,QByteArray)">
+ <add-function signature="operator+(PyByteArray)" return-type="QByteArray">
<inject-code>
- QByteArray ba = QByteArray(PyBytes_AS_STRING(%PYARG_1), PyBytes_GET_SIZE(%PYARG_1)) + *%CPPSELF;
+ QByteArray ba = *%CPPSELF + QByteArray(PyByteArray_AsString(%PYARG_1), PyByteArray_Size(%PYARG_1));
%PYARG_0 = %CONVERTTOPYTHON[QByteArray](ba);
</inject-code>
</add-function>
+ <add-function signature="operator+=(PyByteArray)" return-type="QByteArray">
+ <inject-code>
+ *%CPPSELF += QByteArray(PyByteArray_AsString(%PYARG_1), PyByteArray_Size(%PYARG_1));
+ </inject-code>
+ </add-function>
+ <add-function signature="operator==(PyUnicode)">
+ <inject-code>
+ if (PyUnicode_CheckExact(%PYARG_1)) {
+ Shiboken::AutoDecRef data(PyUnicode_AsASCIIString(%PYARG_1));
+ QByteArray ba = QByteArray(PyBytes_AsString(data.object()), PyBytes_GET_SIZE(data.object()));
+ bool cppResult = %CPPSELF == ba;
+ %PYARG_0 = %CONVERTTOPYTHON[bool](cppResult);
+ }
+ </inject-code>
+ </add-function>
+ <add-function signature="operator!=(PyUnicode)">
+ <inject-code>
+ if (PyUnicode_CheckExact(%PYARG_1)) {
+ Shiboken::AutoDecRef data(PyUnicode_AsASCIIString(%PYARG_1));
+ QByteArray ba = QByteArray(PyBytes_AsString(data.object()), PyBytes_GET_SIZE(data.object()));
+ bool cppResult = %CPPSELF != ba;
+ %PYARG_0 = %CONVERTTOPYTHON[bool](cppResult);
+ }
+ </inject-code>
+ </add-function>
+ <add-function signature="operator&gt;(PyUnicode)">
+ <inject-code>
+ if (PyUnicode_CheckExact(%PYARG_1)) {
+ Shiboken::AutoDecRef data(PyUnicode_AsASCIIString(%PYARG_1));
+ QByteArray ba = QByteArray(PyBytes_AsString(data.object()), PyBytes_GET_SIZE(data.object()));
+ bool cppResult = %CPPSELF &gt; ba;
+ %PYARG_0 = %CONVERTTOPYTHON[bool](cppResult);
+ }
+ </inject-code>
+ </add-function>
+ <add-function signature="operator&gt;=(PyUnicode)">
+ <inject-code>
+ if (PyUnicode_CheckExact(%PYARG_1)) {
+ Shiboken::AutoDecRef data(PyUnicode_AsASCIIString(%PYARG_1));
+ QByteArray ba = QByteArray(PyBytes_AsString(data.object()), PyBytes_GET_SIZE(data.object()));
+ bool cppResult = %CPPSELF &gt;= ba;
+ %PYARG_0 = %CONVERTTOPYTHON[bool](cppResult);
+ }
+ </inject-code>
+ </add-function>
+ <add-function signature="operator&lt;(PyUnicode)">
+ <inject-code>
+ if (PyUnicode_CheckExact(%PYARG_1)) {
+ Shiboken::AutoDecRef data(PyUnicode_AsASCIIString(%PYARG_1));
+ QByteArray ba = QByteArray(PyBytes_AsString(data.object()), PyBytes_GET_SIZE(data.object()));
+ bool cppResult = %CPPSELF &lt; ba;
+ %PYARG_0 = %CONVERTTOPYTHON[bool](cppResult);
+ }
+ </inject-code>
+ </add-function>
+ <add-function signature="operator&lt;=(PyUnicode)">
+ <inject-code>
+ if (PyUnicode_CheckExact(%PYARG_1)) {
+ Shiboken::AutoDecRef data(PyUnicode_AsASCIIString(%PYARG_1));
+ QByteArray ba = QByteArray(PyBytes_AsString(data.object()), PyBytes_GET_SIZE(data.object()));
+ bool cppResult = %CPPSELF &lt;= ba;
+ %PYARG_0 = %CONVERTTOPYTHON[bool](cppResult);
+ }
+ </inject-code>
+ </add-function>
<!-- ### -->
<add-function signature="__repr__" return-type="PyObject*">
<inject-code class="target" position="beginning">
- QByteArray b(PepType(Py_TYPE(%PYSELF))->tp_name);
- PyObject *aux = Shiboken::String::fromStringAndSize(%CPPSELF.constData(), %CPPSELF.size());
- if (PyUnicode_CheckExact(aux)) {
- PyObject *tmp = PyUnicode_AsASCIIString(aux);
- Py_DECREF(aux);
- aux = tmp;
+ PyObject *aux = PyBytes_FromStringAndSize(%CPPSELF.constData(), %CPPSELF.size());
+ if (aux == NULL) {
+ return NULL;
}
- b += "('";
- b += QByteArray(PyBytes_AS_STRING(aux), PyBytes_GET_SIZE(aux));
- b += "')";
- %PYARG_0 = Shiboken::String::fromStringAndSize(b.constData(), b.size());
+ QByteArray b(PepType(Py_TYPE(%PYSELF))->tp_name);
+ #ifdef IS_PY3K
+ %PYARG_0 = PyUnicode_FromFormat("%s(%R)", b.constData(), aux);
+ #else
+ aux = PyObject_Repr(aux);
+ b += "(";
+ b += QByteArray(PyBytes_AS_STRING(aux), PyBytes_GET_SIZE(aux));
+ b += ")";
+ %PYARG_0 = Shiboken::String::fromStringAndSize(b.constData(), b.size());
+ #endif
+ Py_DECREF(aux);
</inject-code>
</add-function>
@@ -2626,14 +2690,21 @@
<inject-code class="target" position="beginning">
if (PyBytes_Check(%PYARG_1)) {
%0 = new QByteArray(PyBytes_AsString(%PYARG_1), PyBytes_GET_SIZE(%PYARG_1));
- } else if (PyUnicode_CheckExact(%PYARG_1)) {
- Shiboken::AutoDecRef data(PyUnicode_AsASCIIString(%PYARG_1));
- %0 = new QByteArray(PyBytes_AsString(data.object()), PyBytes_GET_SIZE(data.object()));
} else if (Shiboken::String::check(%PYARG_1)) {
%0 = new QByteArray(Shiboken::String::toCString(%PYARG_1), Shiboken::String::len(%PYARG_1));
}
</inject-code>
</modify-function>
+ <add-function signature="QByteArray(PyByteArray)" allow-thread="yes">>
+ <inject-code class="target" position="beginning">
+ %0 = new QByteArray(PyByteArray_AsString(%PYARG_1), PyByteArray_Size(%PYARG_1));
+ </inject-code>
+ </add-function>
+ <add-function signature="QByteArray(PyBytes)" allow-thread="yes">
+ <inject-code class="target" position="beginning">
+ %0 = new QByteArray(PyBytes_AS_STRING(%PYARG_1), PyBytes_GET_SIZE(%PYARG_1));
+ </inject-code>
+ </add-function>
<!-- buffer protocol -->
<inject-code class="native" position="beginning" file="glue/qbytearray_bufferprotocol.cpp" />
<inject-code class="target" position="end">
@@ -2664,6 +2735,7 @@
<modify-function signature="number(uint,int)" remove="all"/>
<modify-function signature="number(qulonglong,int)" remove="all"/>
<modify-function signature="operator+=(const char*)" remove="all"/>
+ <modify-function signature="operator+(char,QByteArray)" remove="all"/>
<modify-function signature="operator==(const char*,QByteArray)" remove="all" />
<modify-function signature="operator!=(const char*,QByteArray)" remove="all" />
<modify-function signature="operator&lt;(const char*,QByteArray)" remove="all" />
@@ -2789,7 +2861,16 @@
</modify-function>
<add-function signature="__str__" return-type="PyObject*">
<inject-code class="target" position="beginning">
- %PYARG_0 = Shiboken::String::fromStringAndSize(%CPPSELF.constData(), %CPPSELF.size());
+ PyObject *aux = PyBytes_FromStringAndSize(%CPPSELF.constData(), %CPPSELF.size());
+ if (aux == NULL) {
+ return NULL;
+ }
+ #ifdef IS_PY3K
+ %PYARG_0 = PyObject_Repr(aux);
+ Py_DECREF(aux);
+ #else
+ %PYARG_0 = aux;
+ #endif
</inject-code>
</add-function>
<add-function signature="__len__">
diff --git a/sources/pyside2/PySide2/QtQml/typesystem_qml.xml b/sources/pyside2/PySide2/QtQml/typesystem_qml.xml
index 80a0ed826..4ca776e11 100644
--- a/sources/pyside2/PySide2/QtQml/typesystem_qml.xml
+++ b/sources/pyside2/PySide2/QtQml/typesystem_qml.xml
@@ -121,6 +121,11 @@
</object-type>
<object-type name="QQmlEngine">
<enum-type name="ObjectOwnership" />
+ <modify-function signature="addImageProvider(const QString&amp;,QQmlImageProviderBase*)">
+ <modify-argument index="2">
+ <define-ownership owner="c++"/>
+ </modify-argument>
+ </modify-function>
</object-type>
<object-type name="QQmlExpression">
<modify-function signature="evaluate(bool*)" allow-thread="yes">
diff --git a/sources/pyside2/PySide2/support/signature/mapping.py b/sources/pyside2/PySide2/support/signature/mapping.py
index b8ef3761c..3e05dbcb2 100644
--- a/sources/pyside2/PySide2/support/signature/mapping.py
+++ b/sources/pyside2/PySide2/support/signature/mapping.py
@@ -238,6 +238,7 @@ def init_QtCore():
"QDir.SortFlags(Name | IgnoreCase)": Instance(
"QDir.SortFlags(QDir.Name | QDir.IgnoreCase)"),
"PyBytes": bytes,
+ "PyByteArray": bytearray,
"PyUnicode": Text,
"signed long": int,
"PySide2.QtCore.int": int,
diff --git a/sources/pyside2/doc/conf.py.in b/sources/pyside2/doc/conf.py.in
index 26d99c7ed..2eb4e6bf3 100644
--- a/sources/pyside2/doc/conf.py.in
+++ b/sources/pyside2/doc/conf.py.in
@@ -18,6 +18,7 @@ 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')
# -- General configuration -----------------------------------------------------
@@ -26,7 +27,8 @@ sys.path.append('@pyside_BINARY_DIR@')
#extensions = ['sphinx.ext.todo', 'sphinx.ext.graphviz', 'inheritance_diagram', 'pysideinclude']
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.ifconfig',
'sphinx.ext.coverage', 'sphinx.ext.intersphinx', 'sphinx.ext.todo',
-'sphinx.ext.graphviz', 'inheritance_diagram', 'pysideinclude']
+'sphinx.ext.graphviz', 'inheritance_diagram', 'pysideinclude',
+'sphinx.ext.viewcode']
rst_epilog = """
.. |project| replace:: Qt for Python
@@ -112,7 +114,7 @@ html_theme_path = ['@CMAKE_CURRENT_SOURCE_DIR@/_themes']
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
-html_title = u'PySide2 documentation'
+html_title = u'Qt for Python (Technology Preview)'
# A shorter title for the navigation bar. Default is the same as html_title.
#html_short_title = None
diff --git a/sources/pyside2/doc/gettingstarted.rst b/sources/pyside2/doc/gettingstarted.rst
index 55212b1ba..f24051c18 100644
--- a/sources/pyside2/doc/gettingstarted.rst
+++ b/sources/pyside2/doc/gettingstarted.rst
@@ -12,7 +12,7 @@ With these installed, you are ready to install the |project|
packages using the pip wheel. Run the following command from your command
prompt to install::
- python -m pip install --index-url=http://download.qt.io/snapshots/ci/pyside/5.9/latest pyside2 --trusted-host download.qt.io
+ python -m pip install --index-url=http://download.qt.io/snapshots/ci/pyside/5.11/latest pyside2 --trusted-host download.qt.io
Now that you have |project| installed, you can test your setup by running the following Python
constructs to print version information:
diff --git a/sources/pyside2/doc/index.rst b/sources/pyside2/doc/index.rst
index d505d5759..fa1daec00 100644
--- a/sources/pyside2/doc/index.rst
+++ b/sources/pyside2/doc/index.rst
@@ -61,6 +61,10 @@ Qt Modules
- `Qt AxContainer <PySide2/QtAxContainer/index.html>`_
Provides QAxObject and QAxWidget which act as
containers for COM objects and ActiveX controls.
+ * - `Qt WebEngineCore <PySide2/QtWebEngineCore/index.html>`_
+ Provides the core functionality to integrate web content
+ - `Qt WebEngineWidgets <PySide2/QtWebEngineWidgets/index.html>`_
+ Provides widgets that can handle web content
* - `Qt WebChannel <PySide2/QtWebChannel/index.html>`_
Enables peer-to-peer communication between a server and a client
(HTML/JavaScript or QML application).
diff --git a/sources/pyside2/doc/qtmodules/pyside-qtwebenginecore.qdocconf.in b/sources/pyside2/doc/qtmodules/pyside-qtwebenginecore.qdocconf.in
new file mode 100644
index 000000000..038c803df
--- /dev/null
+++ b/sources/pyside2/doc/qtmodules/pyside-qtwebenginecore.qdocconf.in
@@ -0,0 +1,3 @@
+include(@QT_SRC_DIR@/../qtwebengine/src/webengine/doc/qtwebengine.qdocconf)
+includepaths += -I @QT_SRC_DIR@/../qtwebengine/src/webengine/doc
+include(../pyside-config.qdocconf)
diff --git a/sources/pyside2/doc/qtmodules/pyside-qtwebenginewidgets.qdocconf.in b/sources/pyside2/doc/qtmodules/pyside-qtwebenginewidgets.qdocconf.in
new file mode 100644
index 000000000..038c803df
--- /dev/null
+++ b/sources/pyside2/doc/qtmodules/pyside-qtwebenginewidgets.qdocconf.in
@@ -0,0 +1,3 @@
+include(@QT_SRC_DIR@/../qtwebengine/src/webengine/doc/qtwebengine.qdocconf)
+includepaths += -I @QT_SRC_DIR@/../qtwebengine/src/webengine/doc
+include(../pyside-config.qdocconf)
diff --git a/sources/pyside2/doc/tutorials/examples/images/tabbedbrowser.png b/sources/pyside2/doc/tutorials/examples/images/tabbedbrowser.png
new file mode 100644
index 000000000..655d6b57f
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/examples/images/tabbedbrowser.png
Binary files differ
diff --git a/sources/pyside2/doc/tutorials/examples/tabbedbrowser.rst b/sources/pyside2/doc/tutorials/examples/tabbedbrowser.rst
new file mode 100644
index 000000000..8a2e03110
--- /dev/null
+++ b/sources/pyside2/doc/tutorials/examples/tabbedbrowser.rst
@@ -0,0 +1,57 @@
+**********************
+Web Browser Example
+**********************
+
+The example demonstrates the power and simplicity offered by |project| to developers.
+It uses several |pymodname| submodules to offer a fluid and modern-looking UI that
+is apt for a web browser. The application offers the following features:
+ * Tab-based browsing experience using QTabWidget.
+ * Download manager using a QProgressBar and QWebEngineDownloadItem.
+ * Bookmark manager using QTreeView.
+
+.. image:: images/tabbedbrowser.png
+
+The application's code is organized in several parts for ease of maintenance. For example,
+:code:`DownloadWidget` provides a widget to track progress of a download item. In the following
+sections, these different parts are discussed briefly to help you understand the Python code behind
+them a little better.
+
+BookmarkWidget or :code:`bookmarkwidget.py`
+===========================================
+
+This is a widget that docks to the left of the main window by default. It inherits QTreeView and
+loads a default set of bookmarks using a QStandardItemModel. The model is populated at startup
+for a JSON file, which is updated when you add or remove bookmarks from the tree view.
+
+.. automodule:: bookmarkwidget
+ :members:
+
+DownloadWidget or :code:`downloadwidget.py`
+=============================================
+
+This is a widget that tracks progress of the download item. It inherits QProgressBar to display
+progress of the QWebEngineDownloadItem instance, and offers a context-menu with actions such as Launch,
+Show in folder, Cancel, and Remove.
+
+.. automodule:: downloadwidget
+ :members:
+
+BrowserTabWidget or :code:`browsertabwidget.py`
+===============================================
+
+This is a widget that includes a QWebEngineView to enable viewing web pages. It docks to the right
+of BookmarkWidget in the main window.
+
+.. automodule:: browsertabwidget
+ :members:
+
+MainWindow or :code:`main.py`
+=============================
+
+This is the parent window that collates all the other widgets together to offer the complete package.
+
+.. automodule:: main
+ :members:
+
+
+Try running the example to explore it further.
diff --git a/sources/pyside2/doc/tutorials/index.rst b/sources/pyside2/doc/tutorials/index.rst
index 2e97612aa..18bac57fd 100644
--- a/sources/pyside2/doc/tutorials/index.rst
+++ b/sources/pyside2/doc/tutorials/index.rst
@@ -1,7 +1,22 @@
-PySide tutorials
-****************
+PySide examples and tutorials
+*****************************
-A collection of tutorials and "walkthrough" guides are provided with PySide to help new users get started with PySide development. These documents were ported from C++ to Python and cover a range of topics, from basic use of widgets to step-by-step tutorials that show how an application is put together.
+A collection of examples and tutorials with "walkthrough" guides are
+provided with |project| to help new users get started. These
+documents were ported from C++ to Python and cover a range of topics,
+from basic use of widgets to step-by-step tutorials that show how an
+application is put together.
+
+Examples and demos
+===================
+
+.. toctree::
+ :maxdepth: 1
+
+ examples/tabbedbrowser.rst
+
+Tutorials
+==========
.. toctree::
:maxdepth: 2
diff --git a/sources/pyside2/tests/QtCore/bug_938.py b/sources/pyside2/tests/QtCore/bug_938.py
index b23cbe2f2..98b894735 100644
--- a/sources/pyside2/tests/QtCore/bug_938.py
+++ b/sources/pyside2/tests/QtCore/bug_938.py
@@ -28,13 +28,14 @@
import unittest
from PySide2.QtCore import *
+import py3kcompat as py3k
class TestBug938 (unittest.TestCase):
def testIt(self):
b = QBuffer()
b.open(QBuffer.WriteOnly)
- b.write("\x0023\x005")
+ b.write(py3k.b("\x0023\x005"))
b.close()
self.assertEqual(b.buffer().size(), 5)
diff --git a/sources/pyside2/tests/QtCore/deepcopy_test.py b/sources/pyside2/tests/QtCore/deepcopy_test.py
index ed042ce41..a79ccbe15 100644
--- a/sources/pyside2/tests/QtCore/deepcopy_test.py
+++ b/sources/pyside2/tests/QtCore/deepcopy_test.py
@@ -31,6 +31,7 @@ from copy import deepcopy
from PySide2.QtCore import QByteArray, QDate, QDateTime, QTime, QLine, QLineF
from PySide2.QtCore import Qt, QSize, QSizeF, QRect, QRectF, QDir, QPoint, QPointF
+import py3kcompat as py3k
try:
from PySide2.QtCore import QUuid
HAVE_Q = True
@@ -45,7 +46,7 @@ class DeepCopyHelper:
class QByteArrayDeepCopy(DeepCopyHelper, unittest.TestCase):
def setUp(self):
- self.original = QByteArray('the quick brown fox jumps over the lazy dog')
+ self.original = QByteArray(py3k.b('the quick brown fox jumps over the lazy dog'))
class QDateDeepCopy(DeepCopyHelper, unittest.TestCase):
diff --git a/sources/pyside2/tests/QtCore/qbytearray_concatenation_operator_test.py b/sources/pyside2/tests/QtCore/qbytearray_concatenation_operator_test.py
index 308143d6d..1728c6823 100644
--- a/sources/pyside2/tests/QtCore/qbytearray_concatenation_operator_test.py
+++ b/sources/pyside2/tests/QtCore/qbytearray_concatenation_operator_test.py
@@ -34,38 +34,25 @@
import unittest
from PySide2.QtCore import QByteArray
+import py3kcompat as py3k
class QByteArrayConcatenationOperatorTest(unittest.TestCase):
'''Test cases for QByteArray concatenation with '+' operator'''
def testConcatQByteArrayAndPythonString(self):
- #Test concatenation of a QByteArray with a Python string, in this order
- qba = QByteArray('foo')
- result = qba + '\x00bar'
+ #Test concatenation of a QByteArray with a Python bytes, in this order
+ qba = QByteArray(py3k.b('foo'))
+ result = qba + py3k.b('\x00bar')
self.assertEqual(type(result), QByteArray)
- self.assertEqual(result, 'foo\x00bar')
+ self.assertEqual(result, py3k.b('foo\x00bar'))
def testConcatPythonStringAndQByteArray(self):
- #Test concatenation of a Python string with a QByteArray, in this order
+ #Test concatenation of a Python bytes with a QByteArray, in this order
concat_python_string_add_qbytearray_worked = True
- qba = QByteArray('foo')
- result = 'bar\x00' + qba
+ qba = QByteArray(py3k.b('foo'))
+ result = py3k.b('bar\x00') + qba
self.assertEqual(type(result), QByteArray)
- self.assertEqual(result, 'bar\x00foo')
-
- # NOTICE: Does not makes sense concat a unicode string with a QByteArray, because the
- # user does not know nothing about the internal representation of the unicode string.
- #def testConcatPythonUnicodeAndQByteArray(self):
- ##Test concatenation of a Python unicode object with a QByteArray, in this order
- #concat_python_unicode_add_qbytearray_worked = True
- #qba = QByteArray('foo')
- #result = None
- #try:
- #result = u'ümlaut' + qba
- #except:
- #concat_python_unicode_add_qbytearray_worked = False
- #self.assertTrue(concat_python_unicode_add_qbytearray_worked)
- #self.assertEqual(result.__class__.__name__, 'unicode')
+ self.assertEqual(result, py3k.b('bar\x00foo'))
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qbytearray_operator_iadd_test.py b/sources/pyside2/tests/QtCore/qbytearray_operator_iadd_test.py
index dd569ac55..a345db514 100644
--- a/sources/pyside2/tests/QtCore/qbytearray_operator_iadd_test.py
+++ b/sources/pyside2/tests/QtCore/qbytearray_operator_iadd_test.py
@@ -30,6 +30,7 @@ import unittest
from PySide2.QtCore import QByteArray
from helper.docmodifier import DocModifier
+import py3kcompat as py3k
class BaseQByteArrayOperatorIAdd(object):
'''Base class for QByteArray += operator tests.
@@ -41,31 +42,25 @@ class BaseQByteArrayOperatorIAdd(object):
__metaclass__ = DocModifier
def testSingleString(self):
- '''QByteArray += string of size 1'''
- s = '0'
+ '''QByteArray += bytes of size 1'''
+ s = py3k.b('0')
self.obj += s
self.assertEqual(self.obj, self.orig_obj + s)
self.assertEqual(self.obj.size(), self.orig_obj.size() + len(s))
def testString(self):
- '''QByteArray += string of size > 1'''
- s = 'dummy'
- self.obj += s
+ '''QByteArray += bytes of size > 1'''
+ s = bytearray(py3k.b('dummy'))
+ self.obj += s # XXx iadd support abytearray
self.assertEqual(self.obj, self.orig_obj + s)
self.assertEqual(self.obj.size(), self.orig_obj.size() + len(s))
def testQByteArray(self):
'''QByteArray += QByteArray'''
- s = QByteArray('array')
+ s = QByteArray(py3k.b('array'))
self.obj += s
self.assertEqual(self.obj, self.orig_obj + s)
- def testChar(self):
- '''QByteArray += char (number < 256)'''
- s = ord('a')
- self.obj += s
- self.assertEqual(self.obj, self.orig_obj + s)
- self.assertEqual(self.obj.size(), self.orig_obj.size() + 1)
class NullQByteArrayOperatorIAdd(unittest.TestCase, BaseQByteArrayOperatorIAdd):
'''Test case for operator QByteArray += on null QByteArrays'''
@@ -85,8 +80,8 @@ class ValidQByteArrayOperatorIAdd(unittest.TestCase, BaseQByteArrayOperatorIAdd)
doc_filter = lambda x: x.startswith('test')
def setUp(self):
- self.obj = QByteArray('some byte array')
- self.orig_obj = QByteArray('some byte array')
+ self.obj = QByteArray(py3k.b('some byte array'))
+ self.orig_obj = QByteArray(py3k.b('some byte array'))
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside2/tests/QtCore/qbytearray_operator_test.py b/sources/pyside2/tests/QtCore/qbytearray_operator_test.py
index 09b5f24fb..93140d1e0 100644
--- a/sources/pyside2/tests/QtCore/qbytearray_operator_test.py
+++ b/sources/pyside2/tests/QtCore/qbytearray_operator_test.py
@@ -47,17 +47,12 @@ class QByteArrayOperatorEqual(unittest.TestCase):
def testSimple(self):
#QByteArray(some_string) == QByteArray(some_string)
- string = 'egg snakes'
+ string = py3k.b('egg snakes')
self.assertEqual(QByteArray(string), QByteArray(string))
def testPyString(self):
#QByteArray(string) == string
- string = 'my test string'
- self.assertEqual(QByteArray(string), string)
-
- def testQString(self):
- #QByteArray(string) == string
- string = 'another test string'
+ string = py3k.b('my test string')
self.assertEqual(QByteArray(string), string)
class QByteArrayOperatorAt(unittest.TestCase):
@@ -66,7 +61,7 @@ class QByteArrayOperatorAt(unittest.TestCase):
def testInRange(self):
#QByteArray[x] where x is a valid index
string = 'abcdefgh'
- obj = QByteArray(string)
+ obj = QByteArray(py3k.b(string))
for i in range(len(string)):
self.assertEqual(obj[i], py3k.b(string[i]))
@@ -74,7 +69,7 @@ class QByteArrayOperatorAt(unittest.TestCase):
def testInRangeReverse(self):
#QByteArray[x] where x is a valid index (reverse order)
string = 'abcdefgh'
- obj = QByteArray(string)
+ obj = QByteArray(py3k.b(string))
for i in range(len(string)-1, 0, -1):
self.assertEqual(obj[i], py3k.b(string[i]))
@@ -82,12 +77,12 @@ class QByteArrayOperatorAt(unittest.TestCase):
def testOutOfRange(self):
#QByteArray[x] where x is out of index
- string = '1234567'
+ string = py3k.b('1234567')
obj = QByteArray(string)
self.assertRaises(IndexError, lambda :obj[len(string)])
def testNullStrings(self):
- ba = QByteArray('\x00')
+ ba = QByteArray(py3k.b('\x00'))
self.assertEqual(ba.at(0), '\x00')
self.assertEqual(ba[0], py3k.b('\x00'))
@@ -97,9 +92,9 @@ class QByteArrayOperatorLen(unittest.TestCase):
def testBasic(self):
'''QByteArray __len__'''
self.assertEqual(len(QByteArray()), 0)
- self.assertEqual(len(QByteArray('')), 0)
- self.assertEqual(len(QByteArray(' ')), 1)
- self.assertEqual(len(QByteArray('yabadaba')), 8)
+ self.assertEqual(len(QByteArray(py3k.b(''))), 0)
+ self.assertEqual(len(QByteArray(py3k.b(' '))), 1)
+ self.assertEqual(len(QByteArray(py3k.b('yabadaba'))), 8)
class QByteArrayOperatorStr(unittest.TestCase):
@@ -107,9 +102,9 @@ class QByteArrayOperatorStr(unittest.TestCase):
def testBasic(self):
'''QByteArray __str__'''
- self.assertEqual(QByteArray().__str__(), '')
- self.assertEqual(QByteArray('').__str__(), '')
- self.assertEqual(QByteArray('aaa').__str__(), 'aaa')
+ self.assertEqual(QByteArray().__str__(), str(b''))
+ self.assertEqual(QByteArray(py3k.b('')).__str__(), str(b''))
+ self.assertEqual(QByteArray(py3k.b('aaa')).__str__(), str(b'aaa'))
if __name__ == '__main__':
diff --git a/sources/pyside2/tests/QtCore/qbytearray_test.py b/sources/pyside2/tests/QtCore/qbytearray_test.py
index 672472c42..3f7de66fb 100644
--- a/sources/pyside2/tests/QtCore/qbytearray_test.py
+++ b/sources/pyside2/tests/QtCore/qbytearray_test.py
@@ -1,4 +1,5 @@
-#!/usr/bin/python
+# -*- coding:utf-8 -*-
+# !/usr/bin/python
#############################################################################
##
@@ -35,24 +36,24 @@ import ctypes
import pickle
import py3kcompat as py3k
-from PySide2.QtCore import QByteArray, QSettings, QObject
+from PySide2.QtCore import QByteArray, QSettings, QObject, QDataStream, QIODevice
class QByteArrayTestToNumber(unittest.TestCase):
def testToNumberInt(self):
- obj = QByteArray('37')
+ obj = QByteArray(py3k.b('37'))
self.assertEqual((37, True), obj.toInt())
def testToNumberUShort(self):
- obj = QByteArray('37')
+ obj = QByteArray(py3k.b('37'))
self.assertEqual((37, True), obj.toUShort())
def testToNumberFloat(self):
- obj = QByteArray('37.109')
+ obj = QByteArray(py3k.b('37.109'))
self.assertEqual((ctypes.c_float(37.109).value, True),
obj.toFloat())
def testToNumberDouble(self):
- obj = QByteArray('37.109')
+ obj = QByteArray(py3k.b('37.109'))
self.assertEqual((ctypes.c_double(37.109).value, True),
obj.toDouble())
@@ -69,9 +70,9 @@ class QByteArrayTestToNumber(unittest.TestCase):
def testAppend(self):
b = QByteArray()
- b.append("A")
+ b.append(py3k.b("A"))
self.assertEqual(b.size(), 1)
- b.append("AB")
+ b.append(py3k.b("AB"))
self.assertEqual(b.size(), 3)
@@ -80,7 +81,7 @@ class QByteArraySplit(unittest.TestCase):
def testPathSeparator(self):
#QByteArray.split('/')
- obj = QByteArray(unittest.__file__)
+ obj = QByteArray(py3k.b(unittest.__file__))
self.assertEqual(obj.split('/'), unittest.__file__.split('/'))
class QByteArrayData(unittest.TestCase):
@@ -88,11 +89,11 @@ class QByteArrayData(unittest.TestCase):
'''Test case for QByteArray.data'''
def testData(self):
- url = QByteArray("http://web.openbossa.org/")
- self.assertEqual(url.data(), py3k.b("http://web.openbossa.org/"))
+ url = QByteArray(py3k.b("http://pyside.org"))
+ self.assertEqual(url.data(), py3k.b("http://pyside.org"))
def testDataWithZeros(self):
- s1 = "123\000321"
+ s1 = py3k.b("123\000321")
ba = QByteArray(s1)
s2 = ba.data()
self.assertEqual(py3k.b(s1), s2)
@@ -103,21 +104,21 @@ class QByteArrayOperatorAtSetter(unittest.TestCase):
def testSetterString(self):
'''QByteArray[x] = pythonstring'''
- obj = QByteArray('123456')
- obj[1] = '0'
- self.assertEqual(obj, QByteArray('103456'))
+ obj = QByteArray(py3k.b('123456'))
+ obj[1] = py3k.b('0')
+ self.assertEqual(obj, QByteArray(py3k.b('103456')))
def testSetterStringLarge(self):
'''QByteArray[x] = pythonstring (larget than 1 char)'''
- obj = QByteArray('123456')
- obj[3] = 'abba'
- self.assertEqual(obj, QByteArray('123abba56'))
+ obj = QByteArray(py3k.b('123456'))
+ obj[3] = py3k.b('abba')
+ self.assertEqual(obj, QByteArray(py3k.b('123abba56')))
def testSetterQByteArray(self):
'''QByteArray[x] = qbytearray'''
- obj = QByteArray('123456')
- obj[3] = QByteArray('array')
- self.assertEqual(obj, QByteArray('123array56'))
+ obj = QByteArray(py3k.b('123456'))
+ obj[3] = QByteArray(py3k.b('array'))
+ self.assertEqual(obj, QByteArray(py3k.b('123array56')))
class QByteArrayOperatorAtSetterNegativeIndex(unittest.TestCase):
@@ -125,9 +126,9 @@ class QByteArrayOperatorAtSetterNegativeIndex(unittest.TestCase):
def testSetterNegativeIndex(self):
'''QByteArray[x] = string - negative index'''
- obj = QByteArray('123456')
- obj[-3] = 'array'
- self.assertEqual(obj, QByteArray('123array56'))
+ obj = QByteArray(py3k.b('123456'))
+ obj[-3] = py3k.b('array')
+ self.assertEqual(obj, QByteArray(py3k.b('123array56')))
class QByteArrayOperatorAtSetterLargeIndex(unittest.TestCase):
@@ -136,16 +137,38 @@ class QByteArrayOperatorAtSetterLargeIndex(unittest.TestCase):
def testSetterLargeIndexEmpty(self):
'''QByteArray[x] = somestring - Overflow index on empty string'''
# should pad with spaces if the index is larger
- obj = QByteArray('')
- obj[2] = 'a'
- self.assertEqual(obj, QByteArray(' a'))
+ obj = QByteArray(py3k.b(''))
+ obj[2] = py3k.b('a')
+ self.assertEqual(obj, QByteArray(py3k.b(' a')))
def testSetterLargeIndexNormal(self):
'''QByteArray[x] = somestring - Overflow index on normal string'''
# should pad with spaces if the index is larger
- obj = QByteArray('mystring')
- obj[10] = 'normal'
- self.assertEqual(obj, QByteArray('mystring normal'))
+ obj = QByteArray(py3k.b('mystring'))
+ obj[10] = py3k.b('normal')
+ self.assertEqual(obj, QByteArray(py3k.b('mystring normal')))
+
+class QByteArrayOnQDataStream(unittest.TestCase):
+ '''
+ Bug PYSIDE-232
+ '''
+ def testIt(self):
+ a = QByteArray()
+ b = QDataStream(a, QIODevice.WriteOnly)
+ b.writeUInt16(5000)
+ # The __repr__ not suppose to crash anymore
+ self.assertNotEqual(repr(b), None)
+
+class TestBug664(unittest.TestCase):
+ '''
+ QByteArray.data() should return correct data
+ '''
+ def testIt(self):
+ a = QByteArray(py3k.unicode_('hi 猫').encode('utf-8'))
+ if py3k.IS_PY3K:
+ self.assertEqual(repr(a), "PySide2.QtCore.QByteArray(b'hi \\xe7\\x8c\\xab')")
+ else:
+ self.assertEqual(repr(a), "PySide2.QtCore.QByteArray('hi \\xe7\\x8c\\xab')")
class QByteArrayOnQVariant(unittest.TestCase):
def testQByteArrayOnQVariant(self):
@@ -157,7 +180,7 @@ class TestBug567(unittest.TestCase):
QByteArray should support slices
'''
def testIt(self):
- ba = QByteArray('1234567890')
+ ba = QByteArray(py3k.b('1234567890'))
self.assertEqual(ba[2:4], '34')
self.assertEqual(ba[:4], '1234')
self.assertEqual(ba[4:], '567890')
@@ -176,21 +199,24 @@ class QByteArrayBug514(unittest.TestCase):
class TestPickler(unittest.TestCase):
def testIt(self):
- ba = QByteArray("321\x00123")
+ ba = QByteArray(py3k.b("321\x00123"))
output = pickle.dumps(str(ba))
ba2 = pickle.loads(output)
- self.assertEqual(ba, ba2)
+ self.assertEqual(str(ba), str(ba2))
class QByteArrayBug720(unittest.TestCase):
def testIt(self):
- ba = QByteArray(b"32\"1\x00123")
- self.assertEqual(str(ba), "32\"1\x00123")
- self.assertEqual(repr(ba), "PySide2.QtCore.QByteArray('32\"1\x00123')")
+ ba = QByteArray(py3k.b("32\"1\x00123"))
+ self.assertEqual(str(ba), str(py3k.b("32\"1\x00123")))
+ if py3k.IS_PY3K:
+ self.assertEqual(repr(ba), "PySide2.QtCore.QByteArray(b'32\"1\\x00123')")
+ else:
+ self.assertEqual(repr(ba), "PySide2.QtCore.QByteArray('32\"1\\x00123')")
class QByteArrayImplicitConvert(unittest.TestCase):
def testString(self):
# No implicit conversions from QByteArray to python string
- ba = QByteArray("object name")
+ ba = QByteArray(py3k.b("object name"))
obj = QObject()
self.assertRaises(TypeError, obj.setObjectName, ba)
diff --git a/sources/pyside2/tests/QtCore/qdatastream_test.py b/sources/pyside2/tests/QtCore/qdatastream_test.py
index 3e141fbfe..812c2aab5 100644
--- a/sources/pyside2/tests/QtCore/qdatastream_test.py
+++ b/sources/pyside2/tests/QtCore/qdatastream_test.py
@@ -119,21 +119,21 @@ class QDataStreamShift(unittest.TestCase):
def testQByteArrayValid(self):
'''QDataStream <<>> QByteArray - valid'''
- self.stream << QByteArray("hello")
+ self.stream << QByteArray(py3k.b("hello"))
res = QByteArray()
self.read_stream >> res
- self.assertEqual(res, QByteArray("hello"))
+ self.assertEqual(res, QByteArray(py3k.b("hello")))
def testQByteArrayEmpty(self):
'''QDataStream <<>> QByteArray - empty'''
- self.stream << QByteArray("")
+ self.stream << QByteArray(py3k.b(""))
res = QByteArray()
self.read_stream >> res
- self.assertEqual(res, QByteArray(""))
+ self.assertEqual(res, QByteArray(py3k.b("")))
self.assertTrue(res.isEmpty())
self.assertFalse(res.isNull())
@@ -277,29 +277,29 @@ class QDataStreamShiftBitArray(unittest.TestCase):
'''QDataStream with valid QBitArray'''
data = []
- data.append((QByteArray('\x00\x00\x00\x00'), QDataStream.Ok,
+ data.append((QByteArray(py3k.b('\x00\x00\x00\x00')), QDataStream.Ok,
QBitArray()))
- data.append((QByteArray('\x00\x00\x00\x01\x00'), QDataStream.Ok,
+ data.append((QByteArray(py3k.b('\x00\x00\x00\x01\x00')), QDataStream.Ok,
create_bitarray('0')))
- data.append((QByteArray('\x00\x00\x00\x01\x01'), QDataStream.Ok,
+ data.append((QByteArray(py3k.b('\x00\x00\x00\x01\x01')), QDataStream.Ok,
create_bitarray('1')))
- data.append((QByteArray('\x00\x00\x00\x02\x03'), QDataStream.Ok,
+ data.append((QByteArray(py3k.b('\x00\x00\x00\x02\x03')), QDataStream.Ok,
create_bitarray('11')))
- data.append((QByteArray('\x00\x00\x00\x03\x07'), QDataStream.Ok,
+ data.append((QByteArray(py3k.b('\x00\x00\x00\x03\x07')), QDataStream.Ok,
create_bitarray('111')))
- data.append((QByteArray('\x00\x00\x00\x04\x0f'), QDataStream.Ok,
+ data.append((QByteArray(py3k.b('\x00\x00\x00\x04\x0f')), QDataStream.Ok,
create_bitarray('1111')))
- data.append((QByteArray('\x00\x00\x00\x05\x1f'), QDataStream.Ok,
+ data.append((QByteArray(py3k.b('\x00\x00\x00\x05\x1f')), QDataStream.Ok,
create_bitarray('11111')))
- data.append((QByteArray('\x00\x00\x00\x06\x3f'), QDataStream.Ok,
+ data.append((QByteArray(py3k.b('\x00\x00\x00\x06\x3f')), QDataStream.Ok,
create_bitarray('111111')))
- data.append((QByteArray('\x00\x00\x00\x07\x7f'), QDataStream.Ok,
+ data.append((QByteArray(py3k.b('\x00\x00\x00\x07\x7f')), QDataStream.Ok,
create_bitarray('1111111')))
- data.append((QByteArray('\x00\x00\x00\x07\x7e'), QDataStream.Ok,
+ data.append((QByteArray(py3k.b('\x00\x00\x00\x07\x7e')), QDataStream.Ok,
create_bitarray('0111111')))
- data.append((QByteArray('\x00\x00\x00\x07\x00'), QDataStream.Ok,
+ data.append((QByteArray(py3k.b('\x00\x00\x00\x07\x00')), QDataStream.Ok,
create_bitarray('0000000')))
- data.append((QByteArray('\x00\x00\x00\x07\x39'), QDataStream.Ok,
+ data.append((QByteArray(py3k.b('\x00\x00\x00\x07\x39')), QDataStream.Ok,
create_bitarray('1001110')))
self._check_bitarray(data)
@@ -310,19 +310,19 @@ class QDataStreamShiftBitArray(unittest.TestCase):
data.append((QByteArray(), QDataStream.ReadPastEnd,
QBitArray()))
- data.append((QByteArray('\x00'), QDataStream.ReadPastEnd,
+ data.append((QByteArray(py3k.b('\x00')), QDataStream.ReadPastEnd,
QBitArray()))
- data.append((QByteArray('\x00\x00'), QDataStream.ReadPastEnd,
+ data.append((QByteArray(py3k.b('\x00\x00')), QDataStream.ReadPastEnd,
QBitArray()))
- data.append((QByteArray('\x00\x00\x00'), QDataStream.ReadPastEnd,
+ data.append((QByteArray(py3k.b('\x00\x00\x00')), QDataStream.ReadPastEnd,
QBitArray()))
- data.append((QByteArray('\x00\x00\x00\x01'), QDataStream.ReadPastEnd,
+ data.append((QByteArray(py3k.b('\x00\x00\x00\x01')), QDataStream.ReadPastEnd,
QBitArray()))
- data.append((QByteArray('\x00\x00\x00\x02'), QDataStream.ReadPastEnd,
+ data.append((QByteArray(py3k.b('\x00\x00\x00\x02')), QDataStream.ReadPastEnd,
QBitArray()))
- data.append((QByteArray('\x00\x00\x00\x03'), QDataStream.ReadPastEnd,
+ data.append((QByteArray(py3k.b('\x00\x00\x00\x03')), QDataStream.ReadPastEnd,
QBitArray()))
- data.append((QByteArray('\x00\x00\x00\x04'), QDataStream.ReadPastEnd,
+ data.append((QByteArray(py3k.b('\x00\x00\x00\x04')), QDataStream.ReadPastEnd,
QBitArray()))
self._check_bitarray(data)
@@ -331,7 +331,7 @@ class QDataStreamShiftBitArray(unittest.TestCase):
'''QDataStream reading corrupt data'''
data = []
- data.append((QByteArray('\x00\x00\x00\x01\x02'),
+ data.append((QByteArray(py3k.b('\x00\x00\x00\x01\x02')),
QDataStream.ReadCorruptData,
QBitArray()))
diff --git a/sources/pyside2/tests/QtCore/qfile_test.py b/sources/pyside2/tests/QtCore/qfile_test.py
index 3dae1aaf0..40f861e4c 100644
--- a/sources/pyside2/tests/QtCore/qfile_test.py
+++ b/sources/pyside2/tests/QtCore/qfile_test.py
@@ -80,7 +80,7 @@ class GetCharTest(unittest.TestCase):
self.assertTrue(dir.isValid())
saveFile = QSaveFile(dir.path() + "/test.dat")
self.assertTrue(saveFile.open(QIODevice.WriteOnly))
- saveFile.write("Test")
+ saveFile.write(py3k.b("Test"))
self.assertTrue(saveFile.commit())
self.assertTrue(os.path.exists(QDir.toNativeSeparators(saveFile.fileName())))
diff --git a/sources/pyside2/tests/QtCore/qfileread_test.py b/sources/pyside2/tests/QtCore/qfileread_test.py
index d8c17cebd..19e1ea371 100644
--- a/sources/pyside2/tests/QtCore/qfileread_test.py
+++ b/sources/pyside2/tests/QtCore/qfileread_test.py
@@ -31,6 +31,7 @@ import unittest
import os
from PySide2.QtCore import QIODevice, QTemporaryFile
+import py3kcompat as py3k
class FileChild1(QTemporaryFile):
pass
@@ -48,11 +49,11 @@ class readDataTest(unittest.TestCase):
'''Acquire resources'''
self.filename1 = FileChild1()
self.assertTrue(self.filename1.open())
- self.filename1.write('Test text for testing')
+ self.filename1.write(py3k.b('Test text for testing'))
self.filename2 = FileChild2()
self.assertTrue(self.filename2.open())
- self.filename2.write('Test text for testing')
+ self.filename2.write(py3k.b('Test text for testing'))
def tearDown(self):
'''release resources'''
diff --git a/sources/pyside2/tests/QtCore/qmessageauthenticationcode_test.py b/sources/pyside2/tests/QtCore/qmessageauthenticationcode_test.py
index 392e6f052..867862de5 100644
--- a/sources/pyside2/tests/QtCore/qmessageauthenticationcode_test.py
+++ b/sources/pyside2/tests/QtCore/qmessageauthenticationcode_test.py
@@ -33,10 +33,11 @@
import unittest
from PySide2.QtCore import QCryptographicHash, QMessageAuthenticationCode
+import py3kcompat as py3k
class TestQMessageAuthenticationCode (unittest.TestCase):
def test(self):
- code = QMessageAuthenticationCode(QCryptographicHash.Sha1, 'bla')
+ code = QMessageAuthenticationCode(QCryptographicHash.Sha1, py3k.b('bla'))
result = code.result()
self.assertTrue(result.size() > 0)
print(result.toHex())
diff --git a/sources/pyside2/tests/QtCore/qtextstream_test.py b/sources/pyside2/tests/QtCore/qtextstream_test.py
index 5cc961aec..6af7f46ba 100644
--- a/sources/pyside2/tests/QtCore/qtextstream_test.py
+++ b/sources/pyside2/tests/QtCore/qtextstream_test.py
@@ -102,12 +102,12 @@ class QTextStreamReadLinesFromDevice(unittest.TestCase):
data = []
data.append((QByteArray(), []))
- data.append((QByteArray('\n'), ['']))
- data.append((QByteArray('\r\n'), ['']))
- data.append((QByteArray('ole'), ['ole']))
- data.append((QByteArray('ole\n'), ['ole']))
- data.append((QByteArray('ole\r\n'), ['ole']))
- data.append((QByteArray('ole\r\ndole\r\ndoffen'), ['ole', 'dole', 'doffen']))
+ data.append((QByteArray(py3k.b('\n')), ['']))
+ data.append((QByteArray(py3k.b('\r\n')), ['']))
+ data.append((QByteArray(py3k.b('ole')), ['ole']))
+ data.append((QByteArray(py3k.b('ole\n')), ['ole']))
+ data.append((QByteArray(py3k.b('ole\r\n')), ['ole']))
+ data.append((QByteArray(py3k.b('ole\r\ndole\r\ndoffen')), ['ole', 'dole', 'doffen']))
self._check_data(data)
diff --git a/sources/pyside2/tests/QtCore/qtimezone_test.py b/sources/pyside2/tests/QtCore/qtimezone_test.py
index fb1326e53..3d5bd1714 100644
--- a/sources/pyside2/tests/QtCore/qtimezone_test.py
+++ b/sources/pyside2/tests/QtCore/qtimezone_test.py
@@ -29,10 +29,11 @@
import unittest
from PySide2.QtCore import QTimeZone
+import py3kcompat as py3k
class TestQTimeZone (unittest.TestCase):
def testTimeZone(self):
- id = 'Europe/Berlin'
+ id = py3k.b('Europe/Berlin')
timeZone = QTimeZone(id)
self.assertTrue(timeZone.isValid())
self.assertEqual(timeZone.id(), id)
diff --git a/sources/pyside2/tests/QtCore/repr_test.py b/sources/pyside2/tests/QtCore/repr_test.py
index 343c991ac..0c20c24ec 100644
--- a/sources/pyside2/tests/QtCore/repr_test.py
+++ b/sources/pyside2/tests/QtCore/repr_test.py
@@ -31,6 +31,7 @@ import unittest
from PySide2.QtCore import QByteArray, QDate, QDateTime, QTime, QLine, QLineF
from PySide2.QtCore import Qt, QSize, QSizeF, QRect, QRectF, QPoint, QPointF
+import py3kcompat as py3k
try:
from PySide2.QtCore import QUuid
HAVE_Q = True
@@ -45,7 +46,7 @@ class ReprCopyHelper:
class QByteArrayReprCopy(ReprCopyHelper, unittest.TestCase):
def setUp(self):
- self.original = QByteArray('the quick brown fox jumps over the lazy dog')
+ self.original = QByteArray(py3k.b('the quick brown fox jumps over the lazy dog'))
class QDateReprCopy(ReprCopyHelper, unittest.TestCase):
diff --git a/sources/pyside2/tests/QtCore/unicode_test.py b/sources/pyside2/tests/QtCore/unicode_test.py
index 3326e2e0e..6fa169a71 100644
--- a/sources/pyside2/tests/QtCore/unicode_test.py
+++ b/sources/pyside2/tests/QtCore/unicode_test.py
@@ -35,6 +35,7 @@ import unittest
import py3kcompat as py3k
from PySide2.QtCore import QObject
+from PySide2.QtCore import QByteArray
class UnicodeConversion(unittest.TestCase):
'''Test case for QString to/from Python Unicode conversion'''
diff --git a/sources/pyside2/tests/QtGui/bug_660.py b/sources/pyside2/tests/QtGui/bug_660.py
index a5fc5be91..e19835a3a 100644
--- a/sources/pyside2/tests/QtGui/bug_660.py
+++ b/sources/pyside2/tests/QtGui/bug_660.py
@@ -42,7 +42,7 @@ class MyItemModel(QStandardItemModel):
def mimeData(self,indexes):
self.__mimedata = super(MyItemModel,self).mimeData(indexes)
- self.__mimedata.setData(py3k.unicode_('application/my-form'), 'hi')
+ self.__mimedata.setData(py3k.unicode_('application/my-form'), py3k.b('hi'))
return self.__mimedata
class TestBug660(unittest.TestCase):
diff --git a/sources/pyside2/tests/QtGui/qtextdocumentwriter_test.py b/sources/pyside2/tests/QtGui/qtextdocumentwriter_test.py
index c5166ca18..b9d87ff2b 100644
--- a/sources/pyside2/tests/QtGui/qtextdocumentwriter_test.py
+++ b/sources/pyside2/tests/QtGui/qtextdocumentwriter_test.py
@@ -30,6 +30,7 @@ import unittest
from PySide2.QtGui import QTextDocumentWriter, QTextDocument
from PySide2.QtCore import QBuffer
+import py3kcompat as py3k
class QTextDocumentWriterTest(unittest.TestCase):
@@ -38,7 +39,7 @@ class QTextDocumentWriterTest(unittest.TestCase):
doc = QTextDocument(text)
b = QBuffer()
b.open(QBuffer.ReadWrite)
- writer = QTextDocumentWriter(b, "plaintext");
+ writer = QTextDocumentWriter(b, py3k.b("plaintext"));
writer.write(doc);
b.close()
self.assertEqual(b.buffer(), text)
diff --git a/sources/pyside2/tests/QtNetwork/bug_1084.py b/sources/pyside2/tests/QtNetwork/bug_1084.py
index b9dfd009a..e9d31eae9 100644
--- a/sources/pyside2/tests/QtNetwork/bug_1084.py
+++ b/sources/pyside2/tests/QtNetwork/bug_1084.py
@@ -38,7 +38,7 @@ class QTcpSocketTestCase(unittest.TestCase):
self.sock.connectToHost('127.0.0.1', 25)
def testIt(self):
- self.sock.write(py3k.unicode_('quit'))
+ self.sock.write(py3k.b('quit'))
if __name__ == "__main__":
unittest.main()
diff --git a/sources/pyside2/tests/QtNetwork/bug_446.py b/sources/pyside2/tests/QtNetwork/bug_446.py
index da4e27d42..4fcda65b7 100644
--- a/sources/pyside2/tests/QtNetwork/bug_446.py
+++ b/sources/pyside2/tests/QtNetwork/bug_446.py
@@ -32,10 +32,11 @@ from PySide2.QtCore import *
from PySide2.QtNetwork import *
from helper import UsesQCoreApplication
+import py3kcompat as py3k
class HttpSignalsCase(UsesQCoreApplication):
'''Test case for launching QHttp signals'''
- DATA = "PySide rocks"
+ DATA = py3k.b("PySide rocks")
def onError(self):
self.assertTrue(False)
@@ -48,7 +49,7 @@ class HttpSignalsCase(UsesQCoreApplication):
def onReadReady(self):
data = self.client.read(100)
- self.assertEqual(data.size(), len(HttpSignalsCase.DATA))
+ self.assertEqual(len(data), len(HttpSignalsCase.DATA))
self.assertEqual(data, HttpSignalsCase.DATA)
self.done()
diff --git a/sources/pyside2/tests/QtNetwork/udpsocket_test.py b/sources/pyside2/tests/QtNetwork/udpsocket_test.py
index b20ef134a..ea4f5c8f6 100644
--- a/sources/pyside2/tests/QtNetwork/udpsocket_test.py
+++ b/sources/pyside2/tests/QtNetwork/udpsocket_test.py
@@ -32,6 +32,7 @@ import unittest
from PySide2.QtCore import QUrl, QObject, SIGNAL, QCoreApplication, QTimer
from PySide2.QtNetwork import QUdpSocket, QHostAddress
+import py3kcompat as py3k
class HttpSignalsCase(unittest.TestCase):
'''Test case for bug #124 - readDatagram signature
@@ -57,7 +58,7 @@ class HttpSignalsCase(unittest.TestCase):
def sendPackage(self):
addr = QHostAddress(QHostAddress.LocalHost)
- self.socket.writeDatagram('datagram', addr, 45454)
+ self.socket.writeDatagram(py3k.b('datagram'), addr, 45454)
def callback(self):
while self.server.hasPendingDatagrams():
diff --git a/sources/pyside2/tests/QtOpenGL/qglbuffer_test.py b/sources/pyside2/tests/QtOpenGL/qglbuffer_test.py
index 1ec033471..07e028eff 100644
--- a/sources/pyside2/tests/QtOpenGL/qglbuffer_test.py
+++ b/sources/pyside2/tests/QtOpenGL/qglbuffer_test.py
@@ -49,7 +49,7 @@ class QGLBufferTest(UsesQApplication):
self.assertTrue(b.bufferId() != 0)
self.assertTrue(b.bind())
- data = QByteArray("12345")
+ data = QByteArray(py3k.b("12345"))
b.allocate(data)
self.assertEqual(b.size(), data.size())
diff --git a/sources/pyside2/tests/QtWebEngineCore/web_engine_custom_scheme.py b/sources/pyside2/tests/QtWebEngineCore/web_engine_custom_scheme.py
index 2a110742a..8da2b45f8 100644
--- a/sources/pyside2/tests/QtWebEngineCore/web_engine_custom_scheme.py
+++ b/sources/pyside2/tests/QtWebEngineCore/web_engine_custom_scheme.py
@@ -34,6 +34,7 @@ from PySide2.QtCore import QBuffer, QTimer
from PySide2.QtWidgets import QApplication
from PySide2.QtWebEngineWidgets import QWebEngineView, QWebEngineProfile
from PySide2.QtWebEngineCore import QWebEngineUrlSchemeHandler
+import py3kcompat as py3k
class TestSchemeHandler(QWebEngineUrlSchemeHandler):
def requestStarted(self, request):
@@ -42,16 +43,16 @@ class TestSchemeHandler(QWebEngineUrlSchemeHandler):
return
self.buffer = QBuffer()
- self.buffer.setData("Really nice goodbye text.")
+ self.buffer.setData(py3k.b("Really nice goodbye text."))
self.buffer.aboutToClose.connect(self.buffer.deleteLater)
- request.reply("text/plain;charset=utf-8", self.buffer)
+ request.reply(py3k.b("text/plain;charset=utf-8"), self.buffer)
class MainTest(unittest.TestCase):
def test_SchemeHandlerRedirect(self):
app = QApplication([])
handler = TestSchemeHandler()
profile = QWebEngineProfile.defaultProfile()
- profile.installUrlSchemeHandler("testpy", handler)
+ profile.installUrlSchemeHandler(py3k.b("testpy"), handler)
view = QWebEngineView()
view.loadFinished.connect(app.quit)
QTimer.singleShot(5000, app.quit)
diff --git a/sources/pyside2/tests/QtXml/qdomdocument_test.py b/sources/pyside2/tests/QtXml/qdomdocument_test.py
index 2af37b01a..63f9fd430 100644
--- a/sources/pyside2/tests/QtXml/qdomdocument_test.py
+++ b/sources/pyside2/tests/QtXml/qdomdocument_test.py
@@ -29,26 +29,28 @@
#############################################################################
import unittest
+
from PySide2.QtCore import QByteArray
from PySide2.QtXml import QDomDocument, QDomElement
+import py3kcompat as py3k
class QDomDocumentTest(unittest.TestCase):
def setUp(self):
self.dom = QDomDocument()
- self.goodXmlData = QByteArray('''
+ self.goodXmlData = QByteArray(py3k.b('''
<typesystem package="PySide2.QtXml">
<value-type name="QDomDocument"/>
<value-type name="QDomElement"/>
</typesystem>
- ''')
+ '''))
- self.badXmlData = QByteArray('''
+ self.badXmlData = QByteArray(py3k.b('''
<typesystem package="PySide2.QtXml">
<value-type name="QDomDocument">
</typesystem>
- ''')
+ '''))
def tearDown(self):
del self.dom
diff --git a/sources/pyside2/tests/QtXmlPatterns/import_test.py b/sources/pyside2/tests/QtXmlPatterns/import_test.py
index 26f740368..bbbb7da07 100644
--- a/sources/pyside2/tests/QtXmlPatterns/import_test.py
+++ b/sources/pyside2/tests/QtXmlPatterns/import_test.py
@@ -32,18 +32,19 @@ import unittest
from PySide2.QtCore import *
from PySide2.QtXmlPatterns import QXmlSchema
from helper import UsesQCoreApplication
+import py3kcompat as py3k
class QXmlPatternsTest(UsesQCoreApplication):
def testSchema(self):
- data = QByteArray('''<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+ data = QByteArray(py3k.b('''<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<xsd:schema
xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns=\"http://qt.nokia.com/xmlschematest\"
targetNamespace=\"http://qt.nokia.com/xmlschematest\"
version=\"1.0\"
elementFormDefault=\"qualified\">
- </xsd:schema>''')
+ </xsd:schema>'''))
buf = QBuffer(data)
buf.open(QIODevice.ReadOnly)
diff --git a/sources/pyside2/tests/registry/exists_darwin_5_6_4_ci.py b/sources/pyside2/tests/registry/exists_darwin_5_6_4_ci.py
index d49f08de1..a43dc38af 100644
--- a/sources/pyside2/tests/registry/exists_darwin_5_6_4_ci.py
+++ b/sources/pyside2/tests/registry/exists_darwin_5_6_4_ci.py
@@ -302,7 +302,7 @@ if "PySide2.QtCore" in sys.modules:
"QBuffer.writeData": ('str', 'int'),
# class PySide2.QtCore.QByteArray:
- "QByteArray.__init__": [(), ('PySide2.QtCore.QByteArray',), ('int', 'PySide2.support.signature.typing.Union[str, int]')],
+ "QByteArray.__init__": [(), ('PySide2.QtCore.QByteArray',), ('int', 'PySide2.support.signature.typing.Union[str, int]'), ('bytes',), ('bytearray',)],
"QByteArray.__copy__": (),
"QByteArray.__reduce__": (),
"QByteArray.append": [('PySide2.QtCore.QByteArray',), ('PySide2.support.signature.typing.Union[str, int]',)],
diff --git a/sources/pyside2/tests/registry/exists_darwin_5_9_4_ci.py b/sources/pyside2/tests/registry/exists_darwin_5_9_4_ci.py
index 63a74ff07..45bee7944 100644
--- a/sources/pyside2/tests/registry/exists_darwin_5_9_4_ci.py
+++ b/sources/pyside2/tests/registry/exists_darwin_5_9_4_ci.py
@@ -308,7 +308,7 @@ if "PySide2.QtCore" in sys.modules:
"QBuffer.writeData": ('str', 'int'),
# class PySide2.QtCore.QByteArray:
- "QByteArray.__init__": [(), ('PySide2.QtCore.QByteArray',), ('int', 'Union[str, int]')],
+ "QByteArray.__init__": [(), ('PySide2.QtCore.QByteArray',), ('int', 'Union[str, int]'), ('bytes',), ('bytearray',)],
"QByteArray.__copy__": (),
"QByteArray.__reduce__": (),
"QByteArray.append": [('PySide2.QtCore.QByteArray',), ('Union[str, int]',), ('int', 'Union[str, int]')],
diff --git a/sources/pyside2/tests/registry/exists_linux_5_6_4_ci.py b/sources/pyside2/tests/registry/exists_linux_5_6_4_ci.py
index 7c1188b21..2addd0611 100644
--- a/sources/pyside2/tests/registry/exists_linux_5_6_4_ci.py
+++ b/sources/pyside2/tests/registry/exists_linux_5_6_4_ci.py
@@ -302,7 +302,7 @@ if "PySide2.QtCore" in sys.modules:
"QBuffer.writeData": ('str', 'int'),
# class PySide2.QtCore.QByteArray:
- "QByteArray.__init__": [(), ('PySide2.QtCore.QByteArray',), ('int', 'PySide2.support.signature.typing.Union[str, int]')],
+ "QByteArray.__init__": [(), ('PySide2.QtCore.QByteArray',), ('int', 'PySide2.support.signature.typing.Union[str, int]'), ('bytes',), ('bytearray',)],
"QByteArray.__copy__": (),
"QByteArray.__reduce__": (),
"QByteArray.append": [('PySide2.QtCore.QByteArray',), ('PySide2.support.signature.typing.Union[str, int]',)],
diff --git a/sources/pyside2/tests/registry/exists_linux_5_9_4_ci.py b/sources/pyside2/tests/registry/exists_linux_5_9_4_ci.py
index c552e21f0..636c88a7e 100644
--- a/sources/pyside2/tests/registry/exists_linux_5_9_4_ci.py
+++ b/sources/pyside2/tests/registry/exists_linux_5_9_4_ci.py
@@ -308,7 +308,7 @@ if "PySide2.QtCore" in sys.modules:
"QBuffer.writeData": ('str', 'int'),
# class PySide2.QtCore.QByteArray:
- "QByteArray.__init__": [(), ('PySide2.QtCore.QByteArray',), ('int', 'Union[str, int]')],
+ "QByteArray.__init__": [(), ('PySide2.QtCore.QByteArray',), ('int', 'Union[str, int]'), ('bytes',), ('bytearray',)],
"QByteArray.__copy__": (),
"QByteArray.__reduce__": (),
"QByteArray.append": [('PySide2.QtCore.QByteArray',), ('Union[str, int]',), ('int', 'Union[str, int]')],
diff --git a/sources/pyside2/tests/registry/exists_win32_5_6_4_ci.py b/sources/pyside2/tests/registry/exists_win32_5_6_4_ci.py
index dbf8e59c4..3b4c7441b 100644
--- a/sources/pyside2/tests/registry/exists_win32_5_6_4_ci.py
+++ b/sources/pyside2/tests/registry/exists_win32_5_6_4_ci.py
@@ -304,7 +304,7 @@ if "PySide2.QtCore" in sys.modules:
"QBuffer.writeData": ('str', 'int'),
# class PySide2.QtCore.QByteArray:
- "QByteArray.__init__": [(), ('PySide2.QtCore.QByteArray',), ('int', 'PySide2.support.signature.typing.Union[str, int]')],
+ "QByteArray.__init__": [(), ('PySide2.QtCore.QByteArray',), ('int', 'PySide2.support.signature.typing.Union[str, int]'), ('bytes',), ('bytearray',)],
"QByteArray.__copy__": (),
"QByteArray.__reduce__": (),
"QByteArray.append": [('PySide2.QtCore.QByteArray',), ('PySide2.support.signature.typing.Union[str, int]',)],
diff --git a/sources/pyside2/tests/registry/exists_win32_5_9_4_ci.py b/sources/pyside2/tests/registry/exists_win32_5_9_4_ci.py
index 01e572e21..adf853850 100644
--- a/sources/pyside2/tests/registry/exists_win32_5_9_4_ci.py
+++ b/sources/pyside2/tests/registry/exists_win32_5_9_4_ci.py
@@ -310,7 +310,7 @@ if "PySide2.QtCore" in sys.modules:
"QBuffer.writeData": ('str', 'int'),
# class PySide2.QtCore.QByteArray:
- "QByteArray.__init__": [(), ('PySide2.QtCore.QByteArray',), ('int', 'Union[str, int]')],
+ "QByteArray.__init__": [(), ('PySide2.QtCore.QByteArray',), ('int', 'Union[str, int]'), ('bytes',), ('bytearray',)],
"QByteArray.__copy__": (),
"QByteArray.__reduce__": (),
"QByteArray.append": [('PySide2.QtCore.QByteArray',), ('Union[str, int]',), ('int', 'Union[str, int]')],
diff --git a/sources/pyside2/tests/support/CMakeLists.txt b/sources/pyside2/tests/support/CMakeLists.txt
new file mode 100644
index 000000000..1f18ecf23
--- /dev/null
+++ b/sources/pyside2/tests/support/CMakeLists.txt
@@ -0,0 +1 @@
+PYSIDE_TEST(voidptr_test.py)
diff --git a/sources/pyside2/tests/support/voidptr_test.py b/sources/pyside2/tests/support/voidptr_test.py
new file mode 100644
index 000000000..8179407e5
--- /dev/null
+++ b/sources/pyside2/tests/support/voidptr_test.py
@@ -0,0 +1,47 @@
+#############################################################################
+##
+## Copyright (C) 2018 The Qt Company Ltd.
+## Contact: https://www.qt.io/licensing/
+##
+## This file is part of the test suite of Qt for Python.
+##
+## $QT_BEGIN_LICENSE:GPL-EXCEPT$
+## 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 General Public License Usage
+## Alternatively, this file may be used under the terms of the GNU
+## General Public License version 3 as published by the Free Software
+## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+## 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-3.0.html.
+##
+## $QT_END_LICENSE$
+##
+#############################################################################
+
+import unittest
+from PySide2 import shiboken2
+from PySide2.support import VoidPtr
+from PySide2.QtCore import QByteArray
+
+class PySide2Support(unittest.TestCase):
+
+ def testVoidPtr(self):
+ # Creating a VoidPtr object requires an address of
+ # 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, shiboken2.VoidPtr)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
index d76c788ec..fa9f78ca0 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder.cpp
@@ -1612,7 +1612,7 @@ bool AbstractMetaBuilderPrivate::setupInheritance(AbstractMetaClass *metaClass)
// we only support our own containers and ONLY if there is only one baseclass
if (baseClasses.size() == 1 && baseClasses.constFirst().contains(QLatin1Char('<'))) {
- TypeParser::Info info;
+ TypeInfo info;
ComplexTypeEntry* baseContainerType;
AbstractMetaClass* templ = findTemplateClass(baseClasses.constFirst(), metaClass, &info, &baseContainerType);
if (templ) {
@@ -2343,8 +2343,8 @@ AbstractMetaType *AbstractMetaBuilderPrivate::translateType(const TypeInfo &_typ
return nullptr;
QString errorMessage;
- TypeParser::Info typeInfo = TypeParser::parse(typei.toString(), &errorMessage);
- if (typeInfo.is_busted) {
+ TypeInfo typeInfo = TypeParser::parse(typei.toString(), &errorMessage);
+ if (typeInfo.qualifiedName().isEmpty()) {
qWarning().noquote().nospace() << "Unable to translate type \"" << _typei.toString()
<< "\": " << errorMessage;
return 0;
@@ -2354,43 +2354,43 @@ AbstractMetaType *AbstractMetaBuilderPrivate::translateType(const TypeInfo &_typ
// 2.1 Handle char arrays with unspecified size (aka "const char[]") as "const char*" with
// NativePointerPattern usage.
bool oneDimensionalArrayOfUnspecifiedSize =
- typeInfo.arrays.size() == 1
- && typeInfo.arrays[0].isEmpty();
+ typeInfo.arrayElements().size() == 1
+ && typeInfo.arrayElements().at(0).isEmpty();
bool isConstCharStarCase =
oneDimensionalArrayOfUnspecifiedSize
- && typeInfo.qualified_name.size() == 1
- && typeInfo.qualified_name[0] == QStringLiteral("char")
- && typeInfo.indirections == 0
- && typeInfo.is_constant == 1
- && typeInfo.is_busted == 0
- && typeInfo.referenceType == NoReference
- && typeInfo.template_instantiations.size() == 0;
+ && typeInfo.qualifiedName().size() == 1
+ && typeInfo.qualifiedName().at(0) == QStringLiteral("char")
+ && typeInfo.indirections() == 0
+ && typeInfo.isConstant()
+ && typeInfo.referenceType() == NoReference
+ && typeInfo.arguments().isEmpty();
if (isConstCharStarCase)
- typeInfo.indirections += typeInfo.arrays.size();
+ typeInfo.setIndirections(typeInfo.indirections() + typeInfo.arrayElements().size());
// 2.2 Handle regular arrays.
- if (typeInfo.arrays.size() > 0 && !isConstCharStarCase) {
+ if (!typeInfo.arrayElements().isEmpty() && !isConstCharStarCase) {
TypeInfo newInfo;
- //newInfo.setArguments(typei.arguments());
- newInfo.setIndirections(typei.indirections());
- newInfo.setConstant(typei.isConstant());
- newInfo.setFunctionPointer(typei.isFunctionPointer());
- newInfo.setQualifiedName(typei.qualifiedName());
- newInfo.setReferenceType(typei.referenceType());
- newInfo.setVolatile(typei.isVolatile());
+ //newInfo.setArguments(typeInfo.arguments());
+ newInfo.setIndirections(typeInfo.indirections());
+ newInfo.setConstant(typeInfo.isConstant());
+ newInfo.setFunctionPointer(typeInfo.isFunctionPointer());
+ newInfo.setQualifiedName(typeInfo.qualifiedName());
+ newInfo.setReferenceType(typeInfo.referenceType());
+ newInfo.setVolatile(typeInfo.isVolatile());
AbstractMetaType *elementType = translateType(newInfo);
if (!elementType)
return nullptr;
- for (int i = typeInfo.arrays.size() - 1; i >= 0; --i) {
+ for (int i = typeInfo.arrayElements().size() - 1; i >= 0; --i) {
AbstractMetaType *arrayType = new AbstractMetaType;
arrayType->setArrayElementType(elementType);
- if (!typeInfo.arrays.at(i).isEmpty()) {
+ const QString &arrayElement = typeInfo.arrayElements().at(i);
+ if (!arrayElement.isEmpty()) {
bool _ok;
- const qint64 elems = findOutValueFromString(typeInfo.arrays.at(i), _ok);
+ const qint64 elems = findOutValueFromString(arrayElement, _ok);
if (_ok)
arrayType->setArrayElementCount(int(elems));
}
@@ -2403,7 +2403,7 @@ AbstractMetaType *AbstractMetaBuilderPrivate::translateType(const TypeInfo &_typ
return elementType;
}
- QStringList qualifierList = typeInfo.qualified_name;
+ QStringList qualifierList = typeInfo.qualifiedName();
if (qualifierList.isEmpty()) {
qCWarning(lcShiboken).noquote().nospace()
<< QStringLiteral("horribly broken type '%1'").arg(_typei.toString());
@@ -2468,21 +2468,16 @@ AbstractMetaType *AbstractMetaBuilderPrivate::translateType(const TypeInfo &_typ
AbstractMetaType *metaType = new AbstractMetaType;
metaType->setTypeEntry(type);
- metaType->setIndirections(typeInfo.indirections);
- metaType->setReferenceType(typeInfo.referenceType);
- metaType->setConstant(typeInfo.is_constant);
+ metaType->setIndirections(typeInfo.indirections());
+ metaType->setReferenceType(typeInfo.referenceType());
+ metaType->setConstant(typeInfo.isConstant());
metaType->setOriginalTypeDescription(_typei.toString());
- for (const TypeParser::Info &ta : qAsConst(typeInfo.template_instantiations)) {
- TypeInfo info;
- info.setConstant(ta.is_constant);
- info.setReferenceType(ta.referenceType);
- info.setIndirections(ta.indirections);
-
- info.setFunctionPointer(false);
- info.setQualifiedName(ta.instantiationName().split(colonColon()));
-
- AbstractMetaType *targType = translateType(info);
+ const auto &templateArguments = typeInfo.arguments();
+ for (int t = 0, size = templateArguments.size(); t < size; ++t) {
+ TypeInfo ti = templateArguments.at(t);
+ ti.setQualifiedName(ti.instantiationName());
+ AbstractMetaType *targType = translateType(ti);
if (!targType) {
delete metaType;
return nullptr;
@@ -2671,13 +2666,9 @@ bool AbstractMetaBuilderPrivate::isEnum(const FileModelItem &dom, const QStringL
AbstractMetaClass* AbstractMetaBuilderPrivate::findTemplateClass(const QString &name,
const AbstractMetaClass *context,
- TypeParser::Info *info,
+ TypeInfo *info,
ComplexTypeEntry **baseContainerType) const
{
- TypeParser::Info localInfo;
- if (!info)
- info = &localInfo;
-
TypeDatabase* types = TypeDatabase::instance();
QStringList scope = context->typeEntry()->qualifiedCppName().split(colonColon());
@@ -2686,14 +2677,15 @@ AbstractMetaClass* AbstractMetaBuilderPrivate::findTemplateClass(const QString &
for (int i = scope.size(); i >= 0; --i) {
QString prefix = i > 0 ? QStringList(scope.mid(0, i)).join(colonColon()) + colonColon() : QString();
QString completeName = prefix + name;
- const TypeParser::Info parsed = TypeParser::parse(completeName, &errorMessage);
- if (parsed.is_busted) {
+ const TypeInfo parsed = TypeParser::parse(completeName, &errorMessage);
+ QString qualifiedName = parsed.qualifiedName().join(colonColon());
+ if (qualifiedName.isEmpty()) {
qWarning().noquote().nospace() << "Unable to parse type \"" << completeName
<< "\" while looking for template \"" << name << "\": " << errorMessage;
continue;
}
- *info = parsed;
- QString qualifiedName = info->qualified_name.join(colonColon());
+ if (info)
+ *info = parsed;
AbstractMetaClass* templ = 0;
for (AbstractMetaClass *c : qAsConst(m_templates)) {
@@ -2795,9 +2787,9 @@ AbstractMetaType* AbstractMetaBuilderPrivate::inheritTemplateType(const QVector<
bool AbstractMetaBuilderPrivate::inheritTemplate(AbstractMetaClass *subclass,
const AbstractMetaClass *templateClass,
- const TypeParser::Info &info)
+ const TypeInfo &info)
{
- QVector<TypeParser::Info> targs = info.template_instantiations;
+ QVector<TypeInfo> targs = info.arguments();
QVector<AbstractMetaType *> templateTypes;
if (subclass->isTypeDef()) {
@@ -2810,8 +2802,8 @@ bool AbstractMetaBuilderPrivate::inheritTemplate(AbstractMetaClass *subclass,
subclass->setHasVirtualDestructor(templateClass->hasVirtualDestructor());
}
- for (const TypeParser::Info &i : qAsConst(targs)) {
- QString typeName = i.qualified_name.join(colonColon());
+ for (const TypeInfo &i : qAsConst(targs)) {
+ QString typeName = i.qualifiedName().join(colonColon());
QStringList possibleNames;
possibleNames << subclass->qualifiedCppName() + colonColon() + typeName;
possibleNames << templateClass->qualifiedCppName() + colonColon() + typeName;
@@ -2831,9 +2823,9 @@ bool AbstractMetaBuilderPrivate::inheritTemplate(AbstractMetaClass *subclass,
if (t) {
AbstractMetaType *temporaryType = new AbstractMetaType;
temporaryType->setTypeEntry(t);
- temporaryType->setConstant(i.is_constant);
- temporaryType->setReferenceType(i.referenceType);
- temporaryType->setIndirections(i.indirections);
+ temporaryType->setConstant(i.isConstant());
+ temporaryType->setReferenceType(i.referenceType());
+ temporaryType->setIndirections(i.indirections());
temporaryType->decideUsagePattern();
templateTypes << temporaryType;
} else {
diff --git a/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h
index 959734462..1f4e209db 100644
--- a/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h
+++ b/sources/shiboken2/ApiExtractor/abstractmetabuilder_p.h
@@ -122,18 +122,17 @@ public:
AbstractMetaType *translateType(const AddedFunction::TypeInfo &typeInfo);
AbstractMetaType *translateType(const TypeInfo &type,
bool resolveType = true);
-
qint64 findOutValueFromString(const QString &stringValue, bool &ok);
AbstractMetaClass *findTemplateClass(const QString& name, const AbstractMetaClass *context,
- TypeParser::Info *info = Q_NULLPTR,
+ TypeInfo *info = Q_NULLPTR,
ComplexTypeEntry **baseContainerType = Q_NULLPTR) const;
AbstractMetaClassList getBaseClasses(const AbstractMetaClass *metaClass) const;
bool ancestorHasPrivateCopyConstructor(const AbstractMetaClass *metaClass) const;
bool inheritTemplate(AbstractMetaClass *subclass,
const AbstractMetaClass *templateClass,
- const TypeParser::Info &info);
+ const TypeInfo &info);
AbstractMetaType *inheritTemplateType(const QVector<AbstractMetaType *> &templateTypes,
const AbstractMetaType *metaType,
bool *ok = Q_NULLPTR);
diff --git a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp
index a6b6f2af3..5192e9e76 100644
--- a/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp
+++ b/sources/shiboken2/ApiExtractor/clangparser/clangbuilder.cpp
@@ -379,6 +379,27 @@ static QStringList parseArrayArgs(const CXType &type, QString *typeName)
return result;
}
+// Create qualified name "std::list<std::string>" -> ("std", "list<std::string>")
+static QStringList qualifiedName(const QString &t)
+{
+ QStringList result;
+ int end = t.indexOf(QLatin1Char('<'));
+ if (end == -1)
+ end = t.indexOf(QLatin1Char('('));
+ if (end == -1)
+ end = t.size();
+ int lastPos = 0;
+ while (true) {
+ const int nextPos = t.indexOf(colonColon(), lastPos);
+ if (nextPos < 0 || nextPos >= end)
+ break;
+ result.append(t.mid(lastPos, nextPos - lastPos));
+ lastPos = nextPos + 2;
+ }
+ result.append(t.right(t.size() - lastPos));
+ return result;
+}
+
TypeInfo BuilderPrivate::createTypeInfo(const CXType &type) const
{
if (type.kind == CXType_Pointer) { // Check for function pointers, first.
@@ -439,7 +460,7 @@ TypeInfo BuilderPrivate::createTypeInfo(const CXType &type) const
typeName = typeName.trimmed();
- typeInfo.setQualifiedName(typeName.split(colonColon()));
+ typeInfo.setQualifiedName(qualifiedName(typeName));
// 3320:CINDEX_LINKAGE int clang_getNumArgTypes(CXType T); function ptr types?
return typeInfo;
}
diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp
index 0af4905f4..60a699337 100644
--- a/sources/shiboken2/ApiExtractor/parser/codemodel.cpp
+++ b/sources/shiboken2/ApiExtractor/parser/codemodel.cpp
@@ -238,6 +238,20 @@ QString TypeInfo::toString() const
return tmp;
}
+QStringList TypeInfo::instantiationName() const
+{
+ QStringList result = m_qualifiedName;
+ if (const int argumentCount = m_arguments.size()) {
+ QString &last = result.last();
+ for (int i = 0; i < argumentCount; ++i) {
+ last += i ? QLatin1String(", ") : QLatin1String("< ");
+ last += m_arguments.at(i).toString();
+ }
+ last += QLatin1String(" >");
+ }
+ return result;
+}
+
bool TypeInfo::operator==(const TypeInfo &other) const
{
if (arrayElements().count() != other.arrayElements().count())
diff --git a/sources/shiboken2/ApiExtractor/parser/codemodel.h b/sources/shiboken2/ApiExtractor/parser/codemodel.h
index d0d7b677c..d93aa10d9 100644
--- a/sources/shiboken2/ApiExtractor/parser/codemodel.h
+++ b/sources/shiboken2/ApiExtractor/parser/codemodel.h
@@ -98,6 +98,7 @@ QDebug operator<<(QDebug d, const CodeModel *m);
class TypeInfo
{
+ friend class TypeParser;
public:
TypeInfo() : flags(0), m_referenceType(NoReference) {}
@@ -184,6 +185,8 @@ public:
QString toString() const;
+ QStringList instantiationName() const;
+
static TypeInfo combine(const TypeInfo &__lhs, const TypeInfo &__rhs);
static TypeInfo resolveType(TypeInfo const &__type, CodeModelItem __scope);
diff --git a/sources/shiboken2/ApiExtractor/typeparser.cpp b/sources/shiboken2/ApiExtractor/typeparser.cpp
index 9ef4be346..02c85421b 100644
--- a/sources/shiboken2/ApiExtractor/typeparser.cpp
+++ b/sources/shiboken2/ApiExtractor/typeparser.cpp
@@ -27,6 +27,7 @@
****************************************************************************/
#include "typeparser.h"
+#include <codemodel.h>
#include <QtCore/QDebug>
#include <QtCore/QStack>
@@ -155,19 +156,12 @@ QString Scanner::msgParseError(const QString &why) const
+ QString(m_chars, m_length) + QStringLiteral("\": ") + why;
}
-static TypeParser::Info invalidInfo()
-{
- TypeParser::Info result;
- result.is_busted = true;
- return result;
-}
-
-TypeParser::Info TypeParser::parse(const QString &str, QString *errorMessage)
+TypeInfo TypeParser::parse(const QString &str, QString *errorMessage)
{
Scanner scanner(str);
- Info info;
- QStack<Info *> stack;
+ TypeInfo info;
+ QStack<TypeInfo *> stack;
stack.push(&info);
bool colon_prefix = false;
@@ -177,7 +171,7 @@ TypeParser::Info TypeParser::parse(const QString &str, QString *errorMessage)
Scanner::Token tok = scanner.nextToken(errorMessage);
while (tok != Scanner::NoToken) {
if (tok == Scanner::InvalidToken)
- return invalidInfo();
+ return TypeInfo();
// switch (tok) {
// case Scanner::StarToken: printf(" - *\n"); break;
@@ -197,16 +191,16 @@ TypeParser::Info TypeParser::parse(const QString &str, QString *errorMessage)
switch (tok) {
case Scanner::StarToken:
- ++stack.top()->indirections;
+ ++stack.top()->m_indirections;
break;
case Scanner::AmpersandToken:
- switch (stack.top()->referenceType) {
+ switch (stack.top()->referenceType()) {
case NoReference:
- stack.top()->referenceType = LValueReference;
+ stack.top()->setReferenceType(LValueReference);
break;
case LValueReference:
- stack.top()->referenceType = RValueReference;
+ stack.top()->setReferenceType(RValueReference);
break;
case RValueReference:
const QString message = scanner.msgParseError(QStringLiteral("Too many '&' qualifiers"));
@@ -214,18 +208,18 @@ TypeParser::Info TypeParser::parse(const QString &str, QString *errorMessage)
*errorMessage = message;
else
qWarning().noquote().nospace() << message;
- return invalidInfo();
+ return TypeInfo();
}
break;
case Scanner::LessThanToken:
- stack.top()->template_instantiations << Info();
- stack.push(&stack.top()->template_instantiations.last());
+ stack.top()->m_arguments << TypeInfo();
+ stack.push(&stack.top()->m_arguments.last());
break;
case Scanner::CommaToken:
stack.pop();
- stack.top()->template_instantiations << Info();
- stack.push(&stack.top()->template_instantiations.last());
+ stack.top()->m_arguments << TypeInfo();
+ stack.push(&stack.top()->m_arguments.last());
break;
case Scanner::GreaterThanToken:
@@ -237,7 +231,7 @@ TypeParser::Info TypeParser::parse(const QString &str, QString *errorMessage)
break;
case Scanner::ConstToken:
- stack.top()->is_constant = true;
+ stack.top()->m_constant = true;
break;
case Scanner::OpenParenToken: // function pointers not supported
@@ -247,17 +241,17 @@ TypeParser::Info TypeParser::parse(const QString &str, QString *errorMessage)
*errorMessage = message;
else
qWarning().noquote().nospace() << message;
- return invalidInfo();
+ return TypeInfo();
}
case Scanner::Identifier:
if (in_array) {
array = scanner.identifier();
- } else if (colon_prefix || stack.top()->qualified_name.isEmpty()) {
- stack.top()->qualified_name << scanner.identifier();
+ } else if (colon_prefix || stack.top()->m_qualifiedName.isEmpty()) {
+ stack.top()->m_qualifiedName << scanner.identifier();
colon_prefix = false;
} else {
- stack.top()->qualified_name.last().append(QLatin1Char(' ') + scanner.identifier());
+ stack.top()->m_qualifiedName.last().append(QLatin1Char(' ') + scanner.identifier());
}
break;
@@ -267,7 +261,7 @@ TypeParser::Info TypeParser::parse(const QString &str, QString *errorMessage)
case Scanner::SquareEnd:
in_array = false;
- stack.top()->arrays += array;
+ stack.top()->m_arrayElements += array;
break;
@@ -280,83 +274,3 @@ TypeParser::Info TypeParser::parse(const QString &str, QString *errorMessage)
return info;
}
-
-QString TypeParser::Info::instantiationName() const
-{
- QString s(qualified_name.join(QLatin1String("::")));
- if (!template_instantiations.isEmpty()) {
- QStringList insts;
- for (const Info &info : template_instantiations)
- insts << info.toString();
- s += QLatin1String("< ") + insts.join(QLatin1String(", ")) + QLatin1String(" >");
- }
-
- return s;
-}
-
-QString TypeParser::Info::toString() const
-{
- QString s;
-
- if (is_constant)
- s += QLatin1String("const ");
- s += instantiationName();
- for (int i = 0; i < arrays.size(); ++i)
- s += QLatin1Char('[') + arrays.at(i) + QLatin1Char(']');
- s += QString(indirections, QLatin1Char('*'));
- switch (referenceType) {
- case NoReference:
- break;
- case LValueReference:
- s += QLatin1Char('&');
- break;
- case RValueReference:
- s += QLatin1String("&&");
- break;
- }
- return s;
-}
-
-#ifndef QT_NO_DEBUG_STREAM
-
-static void formatTypeInfo(QDebug &d, const TypeParser::Info &i)
-{
- if (i.is_busted) {
- d << "busted";
- return;
- }
-
- d << '"' << i.qualified_name << '"';
- if (!i.arrays.isEmpty()) {
- d << ", arrays=";
- for (const QString &a : i.arrays)
- d << '[' << a << ']';
- }
- if (!i.template_instantiations.isEmpty()) {
- d << ", template_instantiations=[";
- for (int t = 0, size = i.template_instantiations.size(); t < size; ++t) {
- if (t)
- d << ", ";
- formatTypeInfo(d, i.template_instantiations.at(t));
- }
- d << ']';
- }
- if (i.referenceType != NoReference)
- d << ", refType=" << i.referenceType;
- if (i.is_constant)
- d << ", [const]";
- if (i.indirections > 0)
- d << ", indirections=" << i.indirections;
-}
-
-QDebug operator<<(QDebug d, const TypeParser::Info &i)
-{
- QDebugStateSaver saver(d);
- d.noquote();
- d.nospace();
- d << "TypeParser::Info(";
- formatTypeInfo(d, i);
- d << ')';
- return d;
-}
-#endif // !QT_NO_DEBUG_STREAM
diff --git a/sources/shiboken2/ApiExtractor/typeparser.h b/sources/shiboken2/ApiExtractor/typeparser.h
index e51a2c21a..3b538017a 100644
--- a/sources/shiboken2/ApiExtractor/typeparser.h
+++ b/sources/shiboken2/ApiExtractor/typeparser.h
@@ -31,36 +31,15 @@
#include "parser/codemodel_enums.h"
-#include <QtCore/QList>
#include <QtCore/QString>
-#include <QtCore/QStringList>
#include <QtCore/QVector>
-QT_FORWARD_DECLARE_CLASS(QDebug)
+class TypeInfo;
class TypeParser
{
public:
- struct Info
- {
- Info() : referenceType(NoReference), is_constant(false), is_busted(false), indirections(0) { }
- QStringList qualified_name;
- QStringList arrays;
- QVector<Info> template_instantiations;
- ReferenceType referenceType;
- uint is_constant : 1;
- uint is_busted : 1;
- uint indirections : 6;
-
- QString toString() const;
- QString instantiationName() const;
- };
-
- static Info parse(const QString &str, QString *errorMessage = Q_NULLPTR);
+ static TypeInfo parse(const QString &str, QString *errorMessage = nullptr);
};
-#ifndef QT_NO_DEBUG_STREAM
-QDebug operator<<(QDebug d, const TypeParser::Info &);
-#endif
-
#endif // TYPEPARSER_H
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index bd654f17c..badb6a4cd 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -1988,7 +1988,7 @@ void CppGenerator::writeErrorSection(QTextStream& s, OverloadData& overloadData)
QString strArg;
AbstractMetaType* argType = arg->type();
if (isCString(argType)) {
- strArg = QLatin1String("\" SBK_STR_NAME \"");
+ strArg = QLatin1String("\" SBK_BYTES_NAME \"");
} else if (argType->isPrimitive()) {
const PrimitiveTypeEntry* ptp = reinterpret_cast<const PrimitiveTypeEntry*>(argType->typeEntry());
while (ptp->referencedTypeEntry())
@@ -2025,7 +2025,9 @@ void CppGenerator::writeErrorSection(QTextStream& s, OverloadData& overloadData)
else if (strArg == QLatin1String("PyString"))
strArg = QLatin1String("str");
else if (strArg == QLatin1String("PyBytes"))
- strArg = QLatin1String("\" SBK_STR_NAME \"");
+ strArg = QLatin1String("\" SBK_BYTES_NAME \"");
+ else if (strArg == QLatin1String("PyByteArray"))
+ strArg = QLatin1String("bytearray");
else if (strArg == QLatin1String("PySequence"))
strArg = QLatin1String("list");
else if (strArg == QLatin1String("PyTuple"))
diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp
index 0e2712ec8..b46fbaef2 100644
--- a/sources/shiboken2/libshiboken/basewrapper.cpp
+++ b/sources/shiboken2/libshiboken/basewrapper.cpp
@@ -545,7 +545,7 @@ void init()
PyEval_InitThreads();
//Init private data
- Pep_Init();
+ Pep384_Init();
Shiboken::ObjectType::initPrivateData(SbkObject_TypeF());
diff --git a/sources/shiboken2/libshiboken/pep384impl.cpp b/sources/shiboken2/libshiboken/pep384impl.cpp
index 2707d3716..d2407444d 100644
--- a/sources/shiboken2/libshiboken/pep384impl.cpp
+++ b/sources/shiboken2/libshiboken/pep384impl.cpp
@@ -910,7 +910,7 @@ PepType_GetNameStr(PyTypeObject *type)
*/
void
-Pep_Init()
+Pep384_Init()
{
check_PepTypeObject_valid();
#ifdef Py_LIMITED_API
diff --git a/sources/shiboken2/libshiboken/pep384impl.h b/sources/shiboken2/libshiboken/pep384impl.h
index fc0e3b40e..69e984816 100644
--- a/sources/shiboken2/libshiboken/pep384impl.h
+++ b/sources/shiboken2/libshiboken/pep384impl.h
@@ -564,7 +564,7 @@ extern LIBSHIBOKEN_API PyTypeObject *PepStaticMethod_TypePtr;
*
*/
-LIBSHIBOKEN_API void Pep_Init(void);
+LIBSHIBOKEN_API void Pep384_Init(void);
} // extern "C"
diff --git a/sources/shiboken2/libshiboken/sbkpython.h b/sources/shiboken2/libshiboken/sbkpython.h
index 5fe364a29..a26c318d1 100644
--- a/sources/shiboken2/libshiboken/sbkpython.h
+++ b/sources/shiboken2/libshiboken/sbkpython.h
@@ -76,7 +76,6 @@
#define SbkNumber_Check(X) \
(PyNumber_Check(X) && (!PyInstance_Check(X) || PyObject_HasAttrString(X, "__trunc__")))
#define SBK_NB_BOOL(x) (x).nb_nonzero
- #define SBK_STR_NAME "str"
#define SBK_PyMethod_New(X, Y) PyMethod_New(X, Y, reinterpret_cast<PyObject *>(Py_TYPE(Y)))
#define Py_hash_t long
diff --git a/sources/shiboken2/libshiboken/sbkstring.cpp b/sources/shiboken2/libshiboken/sbkstring.cpp
index b92674383..6ca35f12e 100644
--- a/sources/shiboken2/libshiboken/sbkstring.cpp
+++ b/sources/shiboken2/libshiboken/sbkstring.cpp
@@ -99,18 +99,24 @@ const char* toCString(PyObject* str, Py_ssize_t* len)
{
if (str == Py_None)
return NULL;
-#ifdef IS_PY3K
if (PyUnicode_Check(str)) {
if (len) {
// We need to encode the unicode string into utf8 to know the size of returned char*.
Shiboken::AutoDecRef uniStr(PyUnicode_AsUTF8String(str));
*len = PyBytes_GET_SIZE(uniStr.object());
}
+#ifdef IS_PY3K
// Return unicode from str instead of uniStr, because the lifetime of the returned pointer
// depends on the lifetime of str.
return _PepUnicode_AsString(str);
- }
+#else
+ str = PyUnicode_AsUTF8String(str);
+ if (str == NULL) {
+ return NULL;
+ }
+ return PyString_AsString(str);
#endif
+ }
if (PyBytes_Check(str)) {
if (len)
*len = PyBytes_GET_SIZE(str);
diff --git a/sources/shiboken2/libshiboken/sbkstring.h b/sources/shiboken2/libshiboken/sbkstring.h
index d437f1c77..a6b5fbeed 100644
--- a/sources/shiboken2/libshiboken/sbkstring.h
+++ b/sources/shiboken2/libshiboken/sbkstring.h
@@ -44,9 +44,9 @@
#include "shibokenmacros.h"
#if PY_MAJOR_VERSION >= 3
- #define SBK_STR_NAME "unicode"
+ #define SBK_BYTES_NAME "bytes"
#else
- #define SBK_STR_NAME "str"
+ #define SBK_BYTES_NAME "str"
#endif
namespace Shiboken
diff --git a/sources/shiboken2/libshiboken/voidptr.cpp b/sources/shiboken2/libshiboken/voidptr.cpp
index afb3f4040..94c667598 100644
--- a/sources/shiboken2/libshiboken/voidptr.cpp
+++ b/sources/shiboken2/libshiboken/voidptr.cpp
@@ -55,8 +55,13 @@ typedef struct {
PyObject *SbkVoidPtrObject_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
- SbkVoidPtrObject *self =
- reinterpret_cast<SbkVoidPtrObject *>(PepType(type)->tp_alloc);
+ // PYSIDE-560: It is much safer to first call a function and then do a
+ // type cast than to do everything in one line. The bad construct looked
+ // like this, actual call forgotten:
+ // SbkVoidPtrObject *self =
+ // reinterpret_cast<SbkVoidPtrObject *>(PepType(type)->tp_alloc);
+ PyObject *ob = PepType(type)->tp_alloc(type, 0);
+ SbkVoidPtrObject *self = reinterpret_cast<SbkVoidPtrObject *>(ob);
if (self != 0) {
self->cptr = 0;