aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generator/cppgenerator.cpp15
-rw-r--r--tests/samplebinding/point_test.py1
2 files changed, 13 insertions, 3 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index a8d6c32ae..bd3d6631c 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -3011,7 +3011,8 @@ void CppGenerator::writeRichCompareFunction(QTextStream& s, const AbstractMetaCl
OverloadData overloadData(overloads, this);
const AbstractMetaFunction* rfunc = overloads[0];
- s << INDENT << "case " << ShibokenGenerator::pythonRichCompareOperatorId(rfunc) << ':' << endl;
+ QString operatorId = ShibokenGenerator::pythonRichCompareOperatorId(rfunc);
+ s << INDENT << "case " << operatorId << ':' << endl;
Indentation indent(INDENT);
@@ -3078,8 +3079,16 @@ void CppGenerator::writeRichCompareFunction(QTextStream& s, const AbstractMetaCl
s << INDENT << '}';
}
- s << " else goto " << baseName << "_RichComparison_TypeError;" << endl;
- s << endl;
+ s << " else {" << endl;
+ if (operatorId == "Py_EQ" || operatorId == "Py_NE") {
+ Indentation indent(INDENT);
+ s << INDENT << PYTHON_RETURN_VAR " = " << (operatorId == "Py_EQ" ? "Py_False" : "Py_True") << ';' << endl;
+ s << INDENT << "Py_INCREF(" PYTHON_RETURN_VAR ");" << endl;
+ } else {
+ Indentation indent(INDENT);
+ s << INDENT << "goto " << baseName << "_RichComparison_TypeError;" << endl;
+ }
+ s << INDENT << '}' << endl << endl;
s << INDENT << "break;" << endl;
}
diff --git a/tests/samplebinding/point_test.py b/tests/samplebinding/point_test.py
index ae7cac0bb..3b45db4ad 100644
--- a/tests/samplebinding/point_test.py
+++ b/tests/samplebinding/point_test.py
@@ -54,6 +54,7 @@ class PointTest(unittest.TestCase):
self.assertTrue(pt1 == pt1)
self.assertTrue(pt1 == pt2)
self.assertFalse(pt1 == pt3)
+ self.assertFalse(pt1 == object())
def testNotEqualOperator(self):
'''Test Point class != operator.'''