Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions Lib/test/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@ def spam(cls):
with self.assertRaises(AttributeError):
del Season.SPRING.name

@unittest.expectedFailure # TODO: RUSTPYTHON; RuntimeError: Error calling __set_name__ on '_proto_member' instance failed in 'BadSuper'
def test_bad_new_super(self):
with self.assertRaisesRegex(
TypeError,
Expand Down Expand Up @@ -1903,7 +1902,6 @@ def test_wrong_inheritance_order(self):
class Wrong(Enum, str):
NotHere = 'error before this point'

@unittest.expectedFailure # TODO: RUSTPYTHON; RuntimeError: Error calling __set_name__ on '_proto_member' instance INVALID in 'RgbColor'
def test_raise_custom_error_on_creation(self):
class InvalidRgbColorError(ValueError):
def __init__(self, r, g, b):
Expand Down Expand Up @@ -2591,7 +2589,6 @@ class Test(Base2):
self.assertEqual(Test.flash.flash, 'flashy dynamic')
self.assertEqual(Test.flash.value, 1)

@unittest.expectedFailure # TODO: RUSTPYTHON; RuntimeError: Error calling __set_name__ on '_proto_member' instance grene in 'Color'
def test_no_duplicates(self):
class UniqueEnum(Enum):
def __init__(self, *args):
Expand Down Expand Up @@ -2977,7 +2974,6 @@ def test_empty_globals(self):
local_ls = {}
exec(code, global_ns, local_ls)

@unittest.expectedFailure # TODO: RUSTPYTHON; RuntimeError: Error calling __set_name__ on '_proto_member' instance one in 'FirstFailedStrEnum'
def test_strenum(self):
class GoodStrEnum(StrEnum):
one = '1'
Expand Down Expand Up @@ -3102,7 +3098,6 @@ class ThirdFailedStrEnum(CustomStrEnum):
one = '1'
two = b'2', 'ascii', 9

@unittest.expectedFailure # TODO: RUSTPYTHON; RuntimeError: Error calling __set_name__ on '_proto_member' instance key_type in 'Combined'
def test_missing_value_error(self):
with self.assertRaisesRegex(TypeError, "_value_ not set in __new__"):
class Combined(str, Enum):
Expand Down Expand Up @@ -3389,7 +3384,6 @@ def __new__(cls, c):
self.assertEqual(FlagFromChar.a, 158456325028528675187087900672)
self.assertEqual(FlagFromChar.a|1, 158456325028528675187087900673)

@unittest.expectedFailure # TODO: RUSTPYTHON; RuntimeError: Error calling __set_name__ on '_proto_member' instance A in 'MyEnum'
def test_init_exception(self):
class Base:
def __new__(cls, *args):
Expand Down
43 changes: 25 additions & 18 deletions Lib/test/test_functools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1192,39 +1192,47 @@ def test_disallow_instantiation(self):
self, type(c_functools.cmp_to_key(None))
)

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON; + (mycmp)
def test_cmp_to_signature(self):
return super().test_cmp_to_signature()

@unittest.expectedFailure # TODO: RUSTPYTHON; TypeError: cmp_to_key() got multiple values for argument 'mycmp'
def test_cmp_to_key_arguments(self):
return super().test_cmp_to_key_arguments()

@unittest.expectedFailure # TODO: RUSTPYTHON; TypeError: cmp_to_key() got multiple values for argument 'mycmp'
def test_obj_field(self):
return super().test_obj_field()

@unittest.expectedFailure # TODO: RUSTPYTHON; TypeError: cmp_to_key() takes 1 positional argument but 2 were given
def test_bad_cmp(self):
return super().test_bad_cmp()

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON; TypeError: cmp_to_key() takes 1 positional argument but 2 were given
def test_cmp_to_key(self):
return super().test_cmp_to_key()

@unittest.expectedFailure # TODO: RUSTPYTHON
def test_cmp_to_key_arguments(self):
return super().test_cmp_to_key_arguments()

@unittest.expectedFailure # TODO: RUSTPYTHON
def test_cmp_to_signature(self):
return super().test_cmp_to_signature()

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON; TypeError: cmp_to_key() takes 1 positional argument but 2 were given
def test_hash(self):
return super().test_hash()

@unittest.expectedFailure # TODO: RUSTPYTHON
def test_obj_field(self):
return super().test_obj_field()

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON; TypeError: cmp_to_key() takes 1 positional argument but 2 were given
def test_sort_int(self):
return super().test_sort_int()

@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON; TypeError: cmp_to_key() takes 1 positional argument but 2 were given
def test_sort_int_str(self):
return super().test_sort_int_str()










class TestCmpToKeyPy(TestCmpToKey, unittest.TestCase):
cmp_to_key = staticmethod(py_functools.cmp_to_key)

Expand Down Expand Up @@ -3592,7 +3600,6 @@ class MyClass(metaclass=MyMeta):
):
MyClass.prop

@unittest.expectedFailure # TODO: RUSTPYTHON
def test_reuse_different_names(self):
"""Disallow this case because decorated function a would not be cached."""
with self.assertRaises(TypeError) as ctx:
Expand Down
2 changes: 0 additions & 2 deletions Lib/test/test_subclassinit.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ class A(metaclass=Meta):
d = Descriptor()
self.assertEqual(A, 0)

@unittest.expectedFailure # TODO: RUSTPYTHON; ZeroDivisionError: division by zero
def test_set_name_error(self):
class Descriptor:
def __set_name__(self, owner, name):
Expand All @@ -144,7 +143,6 @@ class NotGoingToWork:
self.assertRegex(str(notes), r'\battr\b')
self.assertRegex(str(notes), r'\bDescriptor\b')

@unittest.expectedFailure # TODO: RUSTPYTHON; RuntimeError: Error calling __set_name__ on 'Descriptor' instance attr in 'NotGoingToWork'
def test_set_name_wrong(self):
class Descriptor:
def __set_name__(self):
Expand Down
12 changes: 7 additions & 5 deletions crates/vm/src/builtins/type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1554,15 +1554,17 @@ impl Constructor for PyType {
})
.collect::<PyResult<Vec<_>>>()?;
for (obj, name, set_name) in attributes {
set_name.call((typ.clone(), name), vm).map_err(|e| {
let err = vm.new_runtime_error(format!(
set_name.call((typ.clone(), name), vm).inspect_err(|e| {
// PEP 678: Add a note to the original exception instead of wrapping it
// (Python 3.12+, gh-77757)
let note = format!(
"Error calling __set_name__ on '{}' instance {} in '{}'",
obj.class().name(),
name,
typ.name()
));
err.set___cause__(Some(e));
err
);
// Ignore result - adding a note is best-effort, the original exception is what matters
drop(vm.call_method(e.as_object(), "add_note", (vm.ctx.new_str(note.as_str()),)));
})?;
}

Expand Down
Loading