aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken2')
-rw-r--r--sources/shiboken2/generator/shiboken2/cppgenerator.cpp5
-rwxr-xr-xsources/shiboken2/tests/otherbinding/extended_multiply_operator_test.py2
2 files changed, 5 insertions, 2 deletions
diff --git a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
index 393f8a850..adec70dd7 100644
--- a/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
+++ b/sources/shiboken2/generator/shiboken2/cppgenerator.cpp
@@ -1764,6 +1764,7 @@ void CppGenerator::writeMethodWrapper(QTextStream &s, const AbstractMetaFunction
s << endl;
/*
+ * This code is intended for shift operations only:
* Make sure reverse <</>> operators defined in other classes (specially from other modules)
* are called. A proper and generic solution would require an reengineering in the operator
* system like the extended converters.
@@ -1778,7 +1779,9 @@ void CppGenerator::writeMethodWrapper(QTextStream &s, const AbstractMetaFunction
&& rfunc->isOperatorOverload();
if (callExtendedReverseOperator) {
QString revOpName = ShibokenGenerator::pythonOperatorFunctionName(rfunc).insert(2, QLatin1Char('r'));
- if (rfunc->isBinaryOperator()) {
+ // For custom classes, operations like __radd__ and __rmul__
+ // will enter an infinite loop.
+ if (rfunc->isBinaryOperator() && revOpName.contains(QLatin1String("shift"))) {
s << INDENT << "if (!isReverse" << endl;
{
Indentation indent(INDENT);
diff --git a/sources/shiboken2/tests/otherbinding/extended_multiply_operator_test.py b/sources/shiboken2/tests/otherbinding/extended_multiply_operator_test.py
index 08541a1f4..0c58fbf5b 100755
--- a/sources/shiboken2/tests/otherbinding/extended_multiply_operator_test.py
+++ b/sources/shiboken2/tests/otherbinding/extended_multiply_operator_test.py
@@ -57,7 +57,7 @@ class PointOperationsWithNumber(unittest.TestCase):
'''sample.Point * other.Number'''
pt = Point(2, 7)
num = Number(11)
- self.assertEqual(pt * num, pt * 11)
+ self.assertEqual(pt * num.value(), pt * 11)
if __name__ == '__main__':
unittest.main()