File tree 1 file changed +6
-2
lines changed
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -281,7 +281,10 @@ impl PyBaseObject {
281
281
282
282
#[ pygetset( name = "__class__" , setter) ]
283
283
fn set_class ( instance : PyObjectRef , value : PyObjectRef , vm : & VirtualMachine ) -> PyResult < ( ) > {
284
- if instance. payload_is :: < PyBaseObject > ( ) {
284
+ if instance. payload_is :: < PyBaseObject > ( )
285
+ || ( instance. class ( ) . fast_issubclass ( vm. ctx . types . module_type )
286
+ && value. class ( ) . fast_issubclass ( vm. ctx . types . module_type ) )
287
+ {
285
288
match value. downcast :: < PyType > ( ) {
286
289
Ok ( cls) => {
287
290
// FIXME(#1979) cls instances might have a payload
@@ -298,7 +301,8 @@ impl PyBaseObject {
298
301
}
299
302
} else {
300
303
Err ( vm. new_type_error (
301
- "__class__ assignment only supported for types without a payload" . to_owned ( ) ,
304
+ "__class__ assignment only supported for mutable types or ModuleType subclasses"
305
+ . to_owned ( ) ,
302
306
) )
303
307
}
304
308
}
You can’t perform that action at this time.
0 commit comments