Skip to content

Commit 72c3a70

Browse files
committed
Relocate vm.del_attr to obj.del_attr
1 parent d6fc20f commit 72c3a70

File tree

4 files changed

+4
-8
lines changed

4 files changed

+4
-8
lines changed

vm/src/frame.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1810,7 +1810,7 @@ impl ExecutingFrame<'_> {
18101810
fn delete_attr(&mut self, vm: &VirtualMachine, attr: bytecode::NameIdx) -> FrameResult {
18111811
let attr_name = self.code.names[attr as usize].clone();
18121812
let parent = self.pop_value();
1813-
vm.del_attr(&parent, attr_name)?;
1813+
parent.del_attr(attr_name, vm)?;
18141814
Ok(None)
18151815
}
18161816

vm/src/protocol/object.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ impl PyObjectRef {
7474
// int PyObject_GenericSetAttr(PyObject *o, PyObject *name, PyObject *value)
7575

7676
pub fn del_attr(&self, attr_name: impl IntoPyStrRef, vm: &VirtualMachine) -> PyResult<()> {
77-
vm.del_attr(self, attr_name)
77+
let attr_name = attr_name.into_pystr_ref(vm);
78+
self.call_set_attr(vm, attr_name, None)
7879
}
7980

8081
// PyObject *PyObject_GenericGetDict(PyObject *o, void *context)

vm/src/stdlib/builtins.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ mod builtins {
186186

187187
#[pyfunction]
188188
fn delattr(obj: PyObjectRef, attr: PyStrRef, vm: &VirtualMachine) -> PyResult<()> {
189-
vm.del_attr(&obj, attr)
189+
obj.del_attr(attr, vm)
190190
}
191191

192192
#[pyfunction]

vm/src/vm.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,11 +1413,6 @@ impl VirtualMachine {
14131413
}
14141414
}
14151415

1416-
pub fn del_attr(&self, obj: &PyObjectRef, attr_name: impl IntoPyStrRef) -> PyResult<()> {
1417-
let attr_name = attr_name.into_pystr_ref(self);
1418-
obj.call_set_attr(self, attr_name, None)
1419-
}
1420-
14211416
// get_method should be used for internal access to magic methods (by-passing
14221417
// the full getattribute look-up.
14231418
pub fn get_method_or_type_error<F>(

0 commit comments

Comments
 (0)