File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,10 @@ impl PyType {
104
104
105
105
* slots. name . get_mut ( ) = Some ( String :: from ( name) ) ;
106
106
107
+ if !slots. flags . has_feature ( PyTypeFlags :: HEAPTYPE ) {
108
+ slots. flags |= PyTypeFlags :: IMMUTABLETYPE
109
+ }
110
+
107
111
let new_type = PyRef :: new_ref (
108
112
PyType {
109
113
base : Some ( base) ,
@@ -707,6 +711,14 @@ impl SetAttr for PyType {
707
711
value : Option < PyObjectRef > ,
708
712
vm : & VirtualMachine ,
709
713
) -> PyResult < ( ) > {
714
+ if zelf. slots . flags . has_feature ( PyTypeFlags :: IMMUTABLETYPE ) {
715
+ return Err ( vm. new_type_error ( format ! (
716
+ "cannot set '{}' attribute of immutable type '{}'" ,
717
+ attr_name,
718
+ zelf. name( )
719
+ ) ) ) ;
720
+ }
721
+
710
722
// TODO: pass PyRefExact instead of &str
711
723
let attr_name = vm. ctx . intern_str ( attr_name. as_str ( ) ) ;
712
724
if let Some ( attr) = zelf. get_class_attr ( attr_name) {
You can’t perform that action at this time.
0 commit comments