@@ -288,12 +288,13 @@ public static void ClearFreeList()
288288
289289 class DelegateCallableObject
290290 {
291- Dictionary < int , List < Method . IMethodCaller > > _callers ;
292- private string _name ;
291+ public string Name { get ; private set ; }
292+
293+ private Dictionary < int , List < Method . IMethodCaller > > _callers ;
293294
294295 public DelegateCallableObject ( string name )
295296 {
296- _name = name ;
297+ Name = name ;
297298 _callers = new Dictionary < int , List < Method . IMethodCaller > > ( ) ;
298299 }
299300
@@ -398,7 +399,6 @@ public IntPtr PyCall(IntPtr self, IntPtr args)
398399 }
399400 }
400401 return Exceptions . RaiseTypeError ( "No match found for given type params" ) ;
401- //return IntPtr.Zero;
402402 }
403403
404404 internal static Type CreateDelegateType ( Type type , Type returnType , Type [ ] paramTypes )
@@ -551,6 +551,12 @@ public static IntPtr tp_call(IntPtr ob, IntPtr args, IntPtr kw)
551551 var self = ( DelegateMethodObject ) GetManagedObject ( ob ) ;
552552 return self . _caller . PyCall ( ob , args ) ;
553553 }
554+
555+ public static IntPtr tp_repr ( IntPtr ob )
556+ {
557+ var self = ( DelegateMethodObject ) GetManagedObject ( ob ) ;
558+ return Runtime . PyString_FromString ( $ "<method '{ self . _caller . Name } '>") ;
559+ }
554560 }
555561
556562 internal class DelegateBoundMethodObject : ExtensionType
@@ -598,6 +604,14 @@ public static IntPtr tp_call(IntPtr ob, IntPtr args, IntPtr kw)
598604 }
599605 FinalizeObject ( self ) ;
600606 }
607+
608+ public static IntPtr tp_repr ( IntPtr ob )
609+ {
610+ var self = ( DelegateBoundMethodObject ) GetManagedObject ( ob ) ;
611+ string type = self . Target == IntPtr . Zero ? "unbound" : "bound" ;
612+ string name = self . Caller . Name ;
613+ return Runtime . PyString_FromString ( $ "<{ type } method '{ name } '>") ;
614+ }
601615 }
602616
603617 internal class DelegateGenericMethodObject : DelegateMethodObject
0 commit comments