@@ -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
@@ -64,6 +65,10 @@ impl PyClassRef {
64
65
PyTuple :: from ( _mro ( & self ) )
65
66
}
66
67
68
+ fn set_mro ( self , _value : PyObjectRef , vm : & mut VirtualMachine ) -> PyResult {
69
+ Err ( vm. new_attribute_error ( "read-only attribute" . to_string ( ) ) )
70
+ }
71
+
67
72
fn dir ( self , vm : & mut VirtualMachine ) -> PyList {
68
73
let attributes = get_attributes ( self ) ;
69
74
let attributes: Vec < PyObjectRef > = attributes
@@ -115,7 +120,11 @@ pub fn init(ctx: &PyContext) {
115
120
extend_class ! ( & ctx, & ctx. type_type, {
116
121
"__call__" => ctx. new_rustfunc( type_call) ,
117
122
"__new__" => ctx. new_rustfunc( type_new) ,
118
- "__mro__" => ctx. new_property( PyClassRef :: mro) ,
123
+ "__mro__" =>
124
+ PropertyBuilder :: new( ctx)
125
+ . add_getter( PyClassRef :: mro)
126
+ . add_setter( PyClassRef :: set_mro)
127
+ . create( ) ,
119
128
"__repr__" => ctx. new_rustfunc( PyClassRef :: repr) ,
120
129
"__prepare__" => ctx. new_rustfunc( PyClassRef :: prepare) ,
121
130
"__getattribute__" => ctx. new_rustfunc( type_getattribute) ,
0 commit comments