Merge pull request #3341 from AP2008/relocate-del_attrs

Relocate `vm.del_attr` to `obj.del_attr`
This commit is contained in:
Jim Fasarakis-Hilliard
2021-10-19 20:27:56 +03:00
committed by GitHub
4 changed files with 4 additions and 8 deletions

View File

@@ -1810,7 +1810,7 @@ impl ExecutingFrame<'_> {
fn delete_attr(&mut self, vm: &VirtualMachine, attr: bytecode::NameIdx) -> FrameResult {
let attr_name = self.code.names[attr as usize].clone();
let parent = self.pop_value();
vm.del_attr(&parent, attr_name)?;
parent.del_attr(attr_name, vm)?;
Ok(None)
}

View File

@@ -74,7 +74,8 @@ impl PyObjectRef {
// int PyObject_GenericSetAttr(PyObject *o, PyObject *name, PyObject *value)
pub fn del_attr(&self, attr_name: impl IntoPyStrRef, vm: &VirtualMachine) -> PyResult<()> {
vm.del_attr(self, attr_name)
let attr_name = attr_name.into_pystr_ref(vm);
self.call_set_attr(vm, attr_name, None)
}
// PyObject *PyObject_GenericGetDict(PyObject *o, void *context)

View File

@@ -186,7 +186,7 @@ mod builtins {
#[pyfunction]
fn delattr(obj: PyObjectRef, attr: PyStrRef, vm: &VirtualMachine) -> PyResult<()> {
vm.del_attr(&obj, attr)
obj.del_attr(attr, vm)
}
#[pyfunction]

View File

@@ -1413,11 +1413,6 @@ impl VirtualMachine {
}
}
pub fn del_attr(&self, obj: &PyObjectRef, attr_name: impl IntoPyStrRef) -> PyResult<()> {
let attr_name = attr_name.into_pystr_ref(self);
obj.call_set_attr(self, attr_name, None)
}
// get_method should be used for internal access to magic methods (by-passing
// the full getattribute look-up.
pub fn get_method_or_type_error<F>(