8000 object.__init__ as slot caller · RustPython/RustPython@205273b · GitHub
[go: up one dir, main page]

Skip to content

Commit 205273b

Browse files
committed
object.__init__ as slot caller
1 parent 5f17d28 commit 205273b

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

vm/src/builtins/object.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,19 @@ impl PyBaseObject {
262262
}
263263

264264
#[pyslot]
265-
#[pymethod(magic)]
266-
fn init(_zelf: PyObjectRef, _args: FuncArgs, _vm: &VirtualMachine) -> PyResult<()> {
265+
fn slot_init(_zelf: PyObjectRef, _args: FuncArgs, _vm: &VirtualMachine) -> PyResult<()> {
267266
Ok(())
268267
}
269268

269+
#[pymethod(magic)]
270+
fn init(zelf: PyObjectRef, args: FuncArgs, vm: &VirtualMachine) -> PyResult<()> {
271+
let init = zelf
272+
.class()
273+
.mro_find_map(|cls| cls.slots.init.load())
274+
.unwrap();
275+
(init)(zelf, args, vm)
276+
}
277+
270278
#[pygetset(name = "__class__")]
271279
fn get_class(obj: PyObjectRef) -> PyTypeRef {
272280
obj.class().to_owned()

0 commit comments

Comments
 (0)
0