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(
13081308 args : FuncArgs ,
13091309 vm : & VirtualMachine ,
13101310) -> 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+ }
13111329 let slot_new = typ
13121330 . deref ( )
13131331 . mro_find_map ( |cls| cls. slots . new . load ( ) )
You can’t perform that action at this time.
0 commit comments