Skip to content

Commit ac26be7

Browse files
authored
Fix getset.__objclass__ (#5853)
1 parent b9b1c85 commit ac26be7

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

vm/src/builtins/getset.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*! Python `attribute` descriptor class. (PyGetSet)
22
33
*/
4-
use super::{PyType, PyTypeRef};
4+
use super::PyType;
55
use crate::{
66
AsObject, Context, Py, PyObject, PyObjectRef, PyPayload, PyResult, VirtualMachine,
77
class::PyClassImpl,
@@ -141,9 +141,10 @@ impl PyGetSet {
141141
format!("{}.{}", self.class.slot_name(), self.name.clone())
142142
}
143143

144-
#[pygetset]
145-
fn __objclass__(&self) -> PyTypeRef {
146-
self.class.to_owned()
144+
#[pymember]
145+
fn __objclass__(vm: &VirtualMachine, zelf: PyObjectRef) -> PyResult {
146+
let zelf: &Py<Self> = zelf.try_to_value(vm)?;
147+
Ok(zelf.class.to_owned().into())
147148
}
148149
}
149150
impl Unconstructible for PyGetSet {}

vm/src/builtins/type.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,7 @@ impl Constructor for PyType {
910910
vm.ctx
911911
.new_getset(
912912
"__dict__",
913-
vm.ctx.types.object_type,
913+
vm.ctx.types.type_type,
914914
subtype_get_dict,
915915
subtype_set_dict,
916916
)

0 commit comments

Comments
 (0)