@@ -9,6 +9,7 @@ use crate::vm::VirtualMachine;
9
9
10
10
use super :: objdict;
11
11
use super :: objlist:: PyList ;
12
+ use super :: objproperty:: PropertyBuilder ;
12
13
use super :: objstr:: { self , PyStringRef } ;
13
14
use super :: objtuple:: PyTuple ;
14
15
@@ -78,6 +79,10 @@ impl PyClassRef {
78
79
PyTuple :: from ( elements)
79
80
}
80
81
82
+ fn set_mro ( self , _value : PyObjectRef , vm : & mut VirtualMachine ) -> PyResult {
83
+ Err ( vm. new_attribute_error ( "read-only attribute" . to_string ( ) ) )
84
+ }
85
+
81
86
fn dir ( self , vm : & mut VirtualMachine ) -> PyList {
82
87
let attributes = get_attributes ( self ) ;
83
88
let attributes: Vec < PyObjectRef > = attributes
@@ -116,7 +121,11 @@ pub fn init(ctx: &PyContext) {
116
121
extend_class ! ( & ctx, & ctx. type_type, {
117
122
"__call__" => ctx. new_rustfunc( type_call) ,
118
123
"__new__" => ctx. new_rustfunc( type_new) ,
119
- "__mro__" => ctx. new_property( PyClassRef :: mro) ,
124
+ "__mro__" =>
125
+ PropertyBuilder :: new( ctx)
126
+ . add_getter( PyClassRef :: mro)
127
+ . add_setter( PyClassRef :: set_mro)
128
+ . create( ) ,
120
129
"__repr__" => ctx. new_rustfunc( PyClassRef :: repr) ,
121
130
"__prepare__" => ctx. new_rustfunc( PyClassRef :: prepare) ,
122
131
"__getattribute__" => ctx. new_rustfunc( type_getattribute) ,
0 commit comments