aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2021-08-21 19:13:46 +0200
committerCristián Maureira-Fredes <cristian.maureira-fredes@qt.io>2022-01-07 14:07:32 +0100
commite5a56d89a6842968c4786a2946390350492c1ca1 (patch)
treebac62ce0ddb0231541ea0c448e00b701121af1d5
parent298cfb2d4a9674ed00b3769fa396a292c075c51c (diff)
py3.10-prep: Fix a binary operator bug in cppgenerator.py
The cppgenerator produced on binary flag operators only checks for cppArg but not for cppSelf. This is wrong, because arguments are sometimes swapped on operator calls. This was recognized in a debug Python build on Python 3.10 . The error checking of this version has a lot improved. [ChangeLog][shiboken6] Binary flags operators did check cppArg only, but not cppSelf. This is necessary when arguments are swapped. Recognized on Python 3.10 due to improved error checks in debug mode. Task-number: PYSIDE-1436 Change-Id: If14e295e6a5a55a6b648c711b7a934733858636a Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> (cherry picked from commit 7034d2ff83248cf9f1a959fdeabf47e5d20c8df8) Reviewed-by: Christian Tismer <tismer@stackless.com>
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index 05d9d97d6..38b596a5f 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -5193,6 +5193,9 @@ void CppGenerator::writeFlagsBinaryOperator(QTextStream &s, const AbstractMetaEn
<< ">(int(PyLong_AsLong(self)));\n";
s << INDENT << "cppArg = static_cast<" << flagsEntry->originalName() << ">(int(PyLong_AsLong("
<< PYTHON_ARG << ")));\n";
+ // PYSIDE-1436: Need to error check self as well because operators are used
+ // sometimes with swapped args.
+ s << INDENT << "if (PyErr_Occurred())\n" << INDENT << "return nullptr;\n";
s << "#else\n";
s << INDENT << CPP_SELF_VAR << " = static_cast<::" << flagsEntry->originalName()
<< ">(int(PyInt_AsLong(self)));\n";