Skip to content

Commit 58744df

Browse files
committed
Revert 08e66b5
which is not required anymore
1 parent facabfe commit 58744df

File tree

2 files changed

+1
-73
lines changed

2 files changed

+1
-73
lines changed

vm/src/obj/objnone.rs

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
use super::objproperty::PyPropertyRef;
2-
use super::objstr::PyStringRef;
31
use super::objtype::PyClassRef;
42
use crate::pyobject::{
5-
IntoPyObject, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TryFromObject,
6-
TypeProtocol,
3+
IntoPyObject, PyClassImpl, PyContext, PyObjectRef, PyRef, PyResult, PyValue, TypeProtocol,
74
};
85
use crate::vm::VirtualMachine;
96

@@ -52,66 +49,6 @@ impl PyNone {
5249
Ok(false)
5350
}
5451

55-
#[pymethod(name = "__getattribute__")]
56-
fn get_attribute(zelf: PyRef<Self>, name: PyStringRef, vm: &VirtualMachine) -> PyResult {
57-
vm_trace!("None.__getattribute__({:?}, {:?})", self, name);
58-
let cls = zelf.class();
59-
60-
// Properties use a comparision with None to determine if they are either invoked by am
61-
// instance binding or a class binding. But if the object itself is None then this detection
62-
// won't work. Instead we call a special function on property that bypasses this check, as
63-
// we are invoking it as a instance binding.
64-
//
65-
// In CPython they instead call the slot tp_descr_get with NULL to indicates it's an
66-
// instance binding.
67-
// https://github.com/python/cpython/blob/master/Objects/typeobject.c#L3281
68-
fn call_descriptor(
69-
descriptor: PyObjectRef,
70-
get_func: PyObjectRef,
71-
obj: PyObjectRef,
72-
cls: PyObjectRef,
73-
vm: &VirtualMachine,
74-
) -> PyResult {
75-
if let Ok(property) = PyPropertyRef::try_from_object(vm, descriptor.clone()) {
76-
property.instance_binding_get(obj, vm)
77-
} else {
78-
vm.invoke(&get_func, vec![descriptor, obj, cls])
79-
}
80-
}
81-
82-
if let Some(attr) = cls.get_attr(name.as_str()) {
83-
let attr_class = attr.class();
84-
if attr_class.has_attr("__set__") {
85-
if let Some(get_func) = attr_class.get_attr("__get__") {
86-
return call_descriptor(
87-
attr,
88-
get_func,
89-
zelf.into_object(),
90-
cls.into_object(),
91-
vm,
92-
);
93-
}
94-
}
95-
}
96-
97-
// None has no attributes and cannot have attributes set on it.
98-
// if let Some(obj_attr) = zelf.as_object().get_attr(name.as_str()) {
99-
// Ok(obj_attr)
100-
// } else
101-
if let Some(attr) = cls.get_attr(name.as_str()) {
102-
let attr_class = attr.class();
103-
if let Some(get_func) = attr_class.get_attr("__get__") {
104-
call_descriptor(attr, get_func, zelf.into_object(), cls.into_object(), vm)
105-
} else {
106-
Ok(attr)
107-
}
108-
} else if let Some(getter) = cls.get_attr("__getattr__") {
109-
vm.invoke(&getter, vec![zelf.into_object(), name.into_object()])
110-
} else {
111-
Err(vm.new_attribute_error(format!("{} has no attribute '{}'", zelf.as_object(), name)))
112-
}
113-
}
114-
11552
#[pymethod(name = "__eq__")]
11653
fn eq(&self, rhs: PyObjectRef, vm: &VirtualMachine) -> PyObjectRef {
11754
if vm.is_none(&rhs) {

vm/src/obj/objproperty.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,6 @@ impl PyProperty {
107107

108108
// Descriptor methods
109109

110-
// specialised version that doesn't check for None
111-
pub(crate) fn instance_binding_get(&self, obj: PyObjectRef, vm: &VirtualMachine) -> PyResult {
112-
if let Some(ref getter) = self.getter.as_ref() {
113-
vm.invoke(getter, obj)
114-
} else {
115-
Err(vm.new_attribute_error("unreadable attribute".to_owned()))
116-
}
117-
}
118-
119110
#[pymethod(name = "__set__")]
120111
fn set(&self, obj: PyObjectRef, value: PyObjectRef, vm: &VirtualMachine) -> PyResult {
121112
if let Some(ref setter) = self.setter.as_ref() {

0 commit comments

Comments
 (0)