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
1 change: 0 additions & 1 deletion Lib/test/test_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,6 @@ def __setattr__(self, name, value) -> None:
with self.assertRaisesRegex(AttributeError, error_msg):
del B().z

@unittest.expectedFailure # TODO: RUSTPYTHON
def testConstructorErrorMessages(self):
# bpo-31506: Improves the error message logic for object_new & object_init

Expand Down
1 change: 0 additions & 1 deletion Lib/test/test_descr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1853,7 +1853,6 @@ class C(list):
__new__ = object.__new__
self.assertRaises(TypeError, C)

@unittest.expectedFailure # TODO: RUSTPYTHON
def test_object_new(self):
class A(object):
pass
Expand Down
9 changes: 5 additions & 4 deletions crates/vm/src/builtins/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,12 @@ impl Initializer for PyBaseObject {
));
}

let typ_new = typ.slots.new.load().map(|f| f as usize);
let object_new = object_type.slots.new.load().map(|f| f as usize);

// if (type->tp_new == object_new) → second error
if typ_new == object_new {
if let (Some(typ_new), Some(object_new)) = (
typ.get_attr(identifier!(vm, __new__)),
object_type.get_attr(identifier!(vm, __new__)),
) && typ_new.is(&object_new)
{
return Err(vm.new_type_error(format!(
"{}.__init__() takes exactly one argument (the instance to initialize)",
typ.name()
Expand Down
Loading