diff --git a/Lib/test/test_collections.py b/Lib/test/test_collections.py index 2f4d7af2a..abfcb1514 100644 --- a/Lib/test/test_collections.py +++ b/Lib/test/test_collections.py @@ -248,8 +248,6 @@ class TestChainMap(unittest.TestCase): for k, v in dict(a=1, B=20, C=30, z=100).items(): # check get self.assertEqual(d.get(k, 100), v) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_union_operators(self): cm1 = ChainMap(dict(a=1, b=2), dict(c=3, d=4)) cm2 = ChainMap(dict(a=10, e=5), dict(b=20, d=4)) diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py index 5e56bec46..ee84a1dbf 100644 --- a/Lib/test/test_enum.py +++ b/Lib/test/test_enum.py @@ -2637,8 +2637,6 @@ class TestIntFlag(unittest.TestCase): self.assertEqual(format(Perm.R, ''), '4') self.assertEqual(format(Perm.R | Perm.X, ''), '5') - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_or(self): Perm = self.Perm for i in Perm: @@ -2660,8 +2658,6 @@ class TestIntFlag(unittest.TestCase): Open = self.Open self.assertIs(Open.RO | Open.CE, Open.CE) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_and(self): Perm = self.Perm RW = Perm.R | Perm.W @@ -2688,8 +2684,6 @@ class TestIntFlag(unittest.TestCase): Open = self.Open self.assertIs(Open.RO & Open.CE, Open.RO) - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_xor(self): Perm = self.Perm for i in Perm: diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py index 1b05cec12..0b471b316 100644 --- a/Lib/test/test_unicode.py +++ b/Lib/test/test_unicode.py @@ -1501,8 +1501,6 @@ class UnicodeTest(string_tests.CommonTest, with self.assertRaises(ValueError): result = format_string % 2.34 - # TODO: RUSTPYTHON - @unittest.expectedFailure def test_issue28598_strsubclass_rhs(self): # A subclass of str with an __rmod__ method should be able to hook # into the % operator diff --git a/vm/src/vm.rs b/vm/src/vm.rs index 263139773..8d3fac70b 100644 --- a/vm/src/vm.rs +++ b/vm/src/vm.rs @@ -1333,6 +1333,19 @@ impl VirtualMachine { reflection: &str, unsupported: fn(&VirtualMachine, &PyObject, &PyObject) -> PyResult, ) -> PyResult { + if rhs.isinstance(&lhs.clone_class()) { + let lop = lhs.get_class_attr(reflection); + let rop = rhs.get_class_attr(reflection); + if let Some((lop, rop)) = lop.zip(rop) { + if !lop.is(&rop) { + if let Ok(r) = self.call_or_unsupported(rhs, lhs, reflection, |vm, _, _| { + Err(vm.new_exception_empty(vm.ctx.exceptions.exception_type.clone())) + }) { + return Ok(r); + } + } + } + } // Try to call the default method self.call_or_unsupported(lhs, rhs, default, move |vm, lhs, rhs| { // Try to call the reflection method