diff options
-rw-r--r-- | build_history/blacklist.txt | 3 | ||||
-rw-r--r-- | sources/pyside6/tests/QtCore/qflags_test.py | 12 | ||||
-rw-r--r-- | sources/shiboken6/generator/shiboken/cppgenerator.cpp | 4 |
3 files changed, 10 insertions, 9 deletions
diff --git a/build_history/blacklist.txt b/build_history/blacklist.txt index b95889b90..58fa349d7 100644 --- a/build_history/blacklist.txt +++ b/build_history/blacklist.txt @@ -18,9 +18,6 @@ darwin py3 [QtCore::qfileread_test] darwin -# Nested exception in Python 3 -[QtCore::qflags_test] - py3 [QtCore::qobject_connect_notify_test] linux darwin diff --git a/sources/pyside6/tests/QtCore/qflags_test.py b/sources/pyside6/tests/QtCore/qflags_test.py index 68d467265..f7bb5033f 100644 --- a/sources/pyside6/tests/QtCore/qflags_test.py +++ b/sources/pyside6/tests/QtCore/qflags_test.py @@ -30,6 +30,7 @@ '''Test cases for QFlags''' +import operator import os import sys import unittest @@ -117,12 +118,13 @@ class QFlagsOnQVariant(unittest.TestCase): class QFlagsWrongType(unittest.TestCase): def testWrongType(self): '''Wrong type passed to QFlags binary operators''' + for op in operator.or_, operator.and_, operator.xor: + for x in '43', 'jabba', QObject, object: + self.assertRaises(TypeError, op, Qt.NoItemFlags, x) + self.assertRaises(TypeError, op, x, Qt.NoItemFlags) + # making sure this actually does not fail all the time + self.assertEqual(operator.or_(Qt.NoItemFlags, 43), 43) - self.assertRaises(TypeError, Qt.NoItemFlags | '43') - self.assertRaises(TypeError, Qt.NoItemFlags & '43') - self.assertRaises(TypeError, 'jabba' & Qt.NoItemFlags) - self.assertRaises(TypeError, 'hut' & Qt.NoItemFlags) - self.assertRaises(TypeError, Qt.NoItemFlags & QObject()) if __name__ == '__main__': unittest.main() diff --git a/sources/shiboken6/generator/shiboken/cppgenerator.cpp b/sources/shiboken6/generator/shiboken/cppgenerator.cpp index 48f7915be..3ca86c3dc 100644 --- a/sources/shiboken6/generator/shiboken/cppgenerator.cpp +++ b/sources/shiboken6/generator/shiboken/cppgenerator.cpp @@ -5218,7 +5218,9 @@ void CppGenerator::writeFlagsBinaryOperator(TextStream &s, const AbstractMetaEnu << CPP_SELF_VAR << " = static_cast<::" << flagsEntry->originalName() << ">(int(PyLong_AsLong(self)));\n" << "cppArg = static_cast<" << flagsEntry->originalName() - << ">(int(PyLong_AsLong(" << PYTHON_ARG << ")));\n\n" + << ">(int(PyLong_AsLong(" << PYTHON_ARG << ")));\n" + << "if (PyErr_Occurred())\n" << indent + << "return nullptr;\n" << outdent << "cppResult = " << CPP_SELF_VAR << " " << cppOpName << " cppArg;\n" << "return "; writeToPythonConversion(s, flagsType, nullptr, QLatin1String("cppResult")); |