Skip to content

Commit d8c3718

Browse files
committed
fix object.__eq__ to give the other side a chance to do the comparison
1 parent 914968f commit d8c3718

File tree

2 files changed

+9
-1
lines changed
  • graalpython

2 files changed

+9
-1
lines changed

graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_binop.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*graalpython.lib-python.3.test.test_binop.FallbackBlockingTests.test_fallback_ne_blocking
2+
*graalpython.lib-python.3.test.test_binop.FallbackBlockingTests.test_fallback_rmethod_blocking
23
*graalpython.lib-python.3.test.test_binop.OperationOrderTests.test_comparison_orders
34
*graalpython.lib-python.3.test.test_binop.RatTestCase.test_add
45
*graalpython.lib-python.3.test.test_binop.RatTestCase.test_constructor

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/object/ObjectBuiltins.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,15 @@ public int hash(Object self) {
234234
public abstract static class EqNode extends PythonBinaryBuiltinNode {
235235
@Specialization
236236
Object eq(Object self, Object other,
237+
@Cached ConditionProfile isEq,
237238
@Cached IsNode isNode) {
238-
return isNode.execute(self, other);
239+
if (isEq.profile(isNode.execute(self, other))) {
240+
return true;
241+
} else {
242+
// Return NotImplemented instead of False, so if two objects are compared, both get
243+
// a chance at the comparison
244+
return PNotImplemented.NOT_IMPLEMENTED;
245+
}
239246
}
240247
}
241248

0 commit comments

Comments
 (0)