Fix properties on the type type

This commit is contained in:
Noah
2019-10-01 21:23:17 +00:00
parent 36a4e107d7
commit 418addcffa

View File

@@ -28,13 +28,10 @@ pub type PyReadOnlyPropertyRef = PyRef<PyReadOnlyProperty>;
#[pyimpl]
impl PyReadOnlyProperty {
#[pymethod(name = "__get__")]
fn get(
zelf: PyRef<Self>,
obj: PyObjectRef,
_owner: OptionalArg<PyClassRef>,
vm: &VirtualMachine,
) -> PyResult {
if obj.is(vm.ctx.none.as_object()) {
fn get(zelf: PyRef<Self>, obj: PyObjectRef, cls: PyClassRef, vm: &VirtualMachine) -> PyResult {
if cls.is(&vm.ctx.types.type_type) {
vm.invoke(&zelf.getter, cls.into_object())
} else if vm.is_none(&obj) {
Ok(zelf.into_object())
} else {
vm.invoke(&zelf.getter, obj)