diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-07-03 22:43:34 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-07-03 22:43:34 +0200 |
commit | 10ce9a37a6b600fec4592fdce9a4b04cb6778cd5 (patch) | |
tree | 2d42d5c08f91f8cab43504edcc44db5cc49939a5 /sources | |
parent | ceeb82693a0240b1dd4f51605ba21413927ee558 (diff) | |
parent | 14728a7f72e64c43b07fe541d856509223764935 (diff) |
Merge remote-tracking branch 'origin/5.15' into dev
Change-Id: I08bddaf2aa407e7499ce05832c9455ca09c1757a
Diffstat (limited to 'sources')
-rw-r--r-- | sources/pyside2/PySide2/QtCore/typesystem_core_common.xml | 9 | ||||
-rw-r--r-- | sources/pyside2/tests/QtCore/CMakeLists.txt | 1 | ||||
-rw-r--r-- | sources/pyside2/tests/QtCore/bug_1313.py | 85 | ||||
-rw-r--r-- | sources/pyside2/tests/QtCore/qbytearray_test.py | 8 | ||||
-rw-r--r-- | sources/pyside2/tests/QtGui/qfontmetrics_test.py | 2 | ||||
-rw-r--r-- | sources/shiboken2/libshiboken/basewrapper.cpp | 8 |
6 files changed, 111 insertions, 2 deletions
diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml index 720cddcc6..1bbd0bfb0 100644 --- a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml +++ b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml @@ -1929,12 +1929,19 @@ <modify-function signature="operator>(const char*,QByteArray)" remove="all"/> <modify-function signature="operator>=(const char*,QByteArray)" remove="all"/> <modify-function signature="operator[](int)const" remove="all"/> - <!-- Those types have the same representation in Python, an overload would be useless. --> + <modify-function signature="operator[](uint)const" remove="all"/> + <!-- Those types have the same representation in Python, an overload + would be useless and cause overflow errors. --> <modify-function signature="setNum(uint,int)" remove="all"/> <modify-function signature="setNum(ushort,int)" remove="all"/> <modify-function signature="setNum(float,char,int)" remove="all"/> <modify-function signature="setNum(short,int)" remove="all"/> <modify-function signature="setNum(qulonglong,int)" remove="all"/> + <modify-function signature="number(uint,int)" remove="all"/> + <modify-function signature="number(ushort,int)" remove="all"/> + <modify-function signature="number(float,char,int)" remove="all"/> + <modify-function signature="number(short,int)" remove="all"/> + <modify-function signature="number(qulonglong,int)" remove="all"/> <!--### --> diff --git a/sources/pyside2/tests/QtCore/CMakeLists.txt b/sources/pyside2/tests/QtCore/CMakeLists.txt index 419d5131b..f3c3ddfdd 100644 --- a/sources/pyside2/tests/QtCore/CMakeLists.txt +++ b/sources/pyside2/tests/QtCore/CMakeLists.txt @@ -26,6 +26,7 @@ PYSIDE_TEST(bug_1019.py) PYSIDE_TEST(bug_1031.py) PYSIDE_TEST(bug_1063.py) PYSIDE_TEST(bug_1069.py) +PYSIDE_TEST(bug_1313.py) PYSIDE_TEST(bug_PYSIDE-42.py) PYSIDE_TEST(bug_PYSIDE-164.py) PYSIDE_TEST(blocking_signals_test.py) diff --git a/sources/pyside2/tests/QtCore/bug_1313.py b/sources/pyside2/tests/QtCore/bug_1313.py new file mode 100644 index 000000000..a24c53b99 --- /dev/null +++ b/sources/pyside2/tests/QtCore/bug_1313.py @@ -0,0 +1,85 @@ +############################################################################# +## +## Copyright (C) 2020 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$ +## +############################################################################# + +''' unit test for BUG #1313 ''' + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide2 import QtCore +import py3kcompat as py3k + + +class MyQObject(QtCore.QObject): + sig = QtCore.Signal() + + +demo_coroutine_definition_code = """ +async def demo_coroutine(): + my_qobject = MyQObject() + my_qobject.sig.connect(lambda: None) +""" + + +if py3k.IS_PY3K: + exec(demo_coroutine_definition_code) + + +@unittest.skipIf(not py3k.IS_PY3K, "Requires Python 3 due to use of async def") +class CoroutineRaisesStopIterationTestCase(unittest.TestCase): + def setUp(self): + self.coroutine = demo_coroutine() + + def testCoroutine(self): + with self.assertRaises(StopIteration): + self.coroutine.send(None) + + +def demo_generator(): + my_qobject = MyQObject() + my_qobject.sig.connect(lambda: None) + return + yield # to make it a generator + + +class GeneratorRaisesStopIterationTestCase(unittest.TestCase): + def setUp(self): + self.generator = demo_generator() + + def testGenerator(self): + with self.assertRaises(StopIteration): + self.generator.send(None) + + +if __name__ == "__main__": + unittest.main() diff --git a/sources/pyside2/tests/QtCore/qbytearray_test.py b/sources/pyside2/tests/QtCore/qbytearray_test.py index 8f1c9c201..c17b7efb1 100644 --- a/sources/pyside2/tests/QtCore/qbytearray_test.py +++ b/sources/pyside2/tests/QtCore/qbytearray_test.py @@ -75,6 +75,14 @@ class QByteArrayTestToNumber(unittest.TestCase): b.setNum(-0.5) self.assertEqual(b, "-0.5") + def testNumber(self): + b = QByteArray.number(py3k.long(-124124)) + self.assertEqual(b, "-124124") + b = QByteArray.number(-124124) + self.assertEqual(b, "-124124") + b = QByteArray.number(-0.5) + self.assertEqual(b, "-0.5") + def testAppend(self): b = QByteArray() b.append(py3k.b("A")) diff --git a/sources/pyside2/tests/QtGui/qfontmetrics_test.py b/sources/pyside2/tests/QtGui/qfontmetrics_test.py index cbf0b0698..4380eae85 100644 --- a/sources/pyside2/tests/QtGui/qfontmetrics_test.py +++ b/sources/pyside2/tests/QtGui/qfontmetrics_test.py @@ -226,7 +226,7 @@ class QCharTest(QFontMetricsFTest): self.assertEqual(type(retCh), QRectF) def testWith(self): - retCh = self.metrics.widthChar('a') + retCh = self.metrics.horizontalAdvance('a') self.assertTrue(retCh > 0) if __name__ == '__main__': diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp index d7184569b..4c15582e9 100644 --- a/sources/shiboken2/libshiboken/basewrapper.cpp +++ b/sources/shiboken2/libshiboken/basewrapper.cpp @@ -410,6 +410,11 @@ static void SbkDeallocWrapperCommon(PyObject *pyObj, bool canDelete) } } + PyObject *error_type, *error_value, *error_traceback; + + /* Save the current exception, if any. */ + PyErr_Fetch(&error_type, &error_value, &error_traceback); + if (canDelete) { if (sotp->is_multicpp) { Shiboken::DtorAccumulatorVisitor visitor(sbkObj); @@ -429,6 +434,9 @@ static void SbkDeallocWrapperCommon(PyObject *pyObj, bool canDelete) Shiboken::Object::deallocData(sbkObj, true); } + /* Restore the saved exception. */ + PyErr_Restore(error_type, error_value, error_traceback); + if (needTypeDecref) Py_DECREF(pyType); if (PepRuntime_38_flag) { |