File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -1308,6 +1308,24 @@ pub(crate) fn call_slot_new(
1308
1308
args : FuncArgs ,
1309
1309
vm : & VirtualMachine ,
1310
1310
) -> PyResult {
1311
+ let mut staticbase = Some ( subtype. clone ( ) ) ;
1312
+ while let Some ( ref basetype) = staticbase {
1313
+ if ( basetype. flags ( ) & PyTypeFlags :: HEAPTYPE . bits ( ) ) != 0 {
1314
+ staticbase = basetype. base ( ) . clone ( ) ;
1315
+ } else {
1316
+ break ;
1317
+ }
1318
+ }
1319
+ if let Some ( ref basetype) = staticbase {
1320
+ if !typ. fast_issubclass ( basetype) {
1321
+ return Err ( vm. new_type_error ( format ! (
1322
+ "{}.__new__({}) is not safe, use {}.__new__()" ,
1323
+ typ. name( ) ,
1324
+ subtype. name( ) ,
1325
+ basetype. name( )
1326
+ ) ) ) ;
1327
+ }
1328
+ }
1311
1329
let slot_new = typ
1312
1330
. deref ( )
1313
1331
. mro_find_map ( |cls| cls. slots . new . load ( ) )
You can’t perform that action at this time.
0 commit comments