@@ -902,7 +902,7 @@ impl VirtualMachine {
902
902
}
903
903
904
904
pub fn to_repr ( & self , obj : & PyObjectRef ) -> PyResult < PyStrRef > {
905
- self . with_recursion ( " while getting the repr of an object" , || {
905
+ self . with_recursion ( "while getting the repr of an object" , || {
906
906
let repr = self . call_special_method ( obj. clone ( ) , "__repr__" , ( ) ) ?;
907
907
repr. try_into_value ( self )
908
908
} )
@@ -1057,15 +1057,16 @@ impl VirtualMachine {
1057
1057
1058
1058
if let Ok ( tuple) = PyTupleRef :: try_from_object ( self , cls. clone ( ) ) {
1059
1059
for typ in tuple. as_slice ( ) . iter ( ) {
1060
- if self . isinstance ( obj, typ) ? {
1060
+ if self . with_recursion ( "in __instancecheck__" , || self . isinstance ( obj, typ) ) ? {
1061
1061
return Ok ( true ) ;
1062
1062
}
1063
1063
}
1064
1064
return Ok ( false ) ;
1065
1065
}
1066
1066
1067
1067
if let Ok ( meth) = self . get_special_method ( cls. clone ( ) , "__instancecheck__" ) ? {
1068
- let ret = meth. invoke ( ( obj. clone ( ) , ) , self ) ?;
1068
+ let ret =
1069
+ self . with_recursion ( "in __instancecheck__" , || meth. invoke ( ( obj. clone ( ) , ) , self ) ) ?;
1069
1070
return ret. try_to_bool ( self ) ;
1070
1071
}
1071
1072
@@ -1139,15 +1140,17 @@ impl VirtualMachine {
1139
1140
1140
1141
if let Ok ( tuple) = PyTupleRef :: try_from_object ( self , cls. clone ( ) ) {
1141
1142
for typ in tuple. as_slice ( ) . iter ( ) {
1142
- if self . issubclass ( subclass, typ) ? {
1143
+ if self . with_recursion ( "in __subclasscheck__" , || self . issubclass ( subclass, typ) ) ? {
1143
1144
return Ok ( true ) ;
1144
1145
}
1145
1146
}
1146
1147
return Ok ( false ) ;
1147
1148
}
1148
1149
1149
1150
if let Ok ( meth) = self . get_special_method ( cls. clone ( ) , "__subclasscheck__" ) ? {
1150
- let ret = meth. invoke ( ( subclass. clone ( ) , ) , self ) ?;
1151
+ let ret = self . with_recursion ( "in __subclasscheck__" , || {
1152
+ meth. invoke ( ( subclass. clone ( ) , ) , self )
1153
+ } ) ?;
1151
1154
return ret. try_to_bool ( self ) ;
1152
1155
}
1153
1156
0 commit comments