@@ -599,6 +599,40 @@ internal virtual IntPtr Invoke(IntPtr inst, IntPtr args, IntPtr kw, MethodBase i
599
599
return Invoke ( inst , args , kw , info , null ) ;
600
600
}
601
601
602
+ protected static void AppendArgumentTypes ( StringBuilder to , IntPtr args )
603
+ {
604
+ long argCount = Runtime . PyTuple_Size ( args ) ;
605
+ to . Append ( "(" ) ;
606
+ for ( long argIndex = 0 ; argIndex < argCount ; argIndex ++ )
607
+ {
608
+ var arg = Runtime . PyTuple_GetItem ( args , argIndex ) ;
609
+ if ( arg != IntPtr . Zero )
610
+ {
611
+ var type = Runtime . PyObject_Type ( arg ) ;
612
+ if ( type != IntPtr . Zero )
613
+ {
614
+ try
615
+ {
616
+ var description = Runtime . PyObject_Unicode ( type ) ;
617
+ if ( description != IntPtr . Zero )
618
+ {
619
+ to . Append ( Runtime . GetManagedString ( description ) ) ;
620
+ Runtime . XDecref ( description ) ;
621
+ }
622
+ }
623
+ finally
624
+ {
625
+ Runtime . XDecref ( type ) ;
626
+ }
627
+ }
628
+ }
629
+
630
+ if ( argIndex + 1 < argCount )
631
+ to . Append ( ", " ) ;
632
+ }
633
+ to . Append ( ')' ) ;
634
+ }
635
+
602
636
internal virtual IntPtr Invoke ( IntPtr inst , IntPtr args , IntPtr kw , MethodBase info , MethodInfo [ ] methodinfo )
603
637
{
604
638
Binding binding = Bind ( inst , args , kw , info , methodinfo ) ;
@@ -613,29 +647,8 @@ internal virtual IntPtr Invoke(IntPtr inst, IntPtr args, IntPtr kw, MethodBase i
613
647
value . Append ( $ " for { methodinfo [ 0 ] . Name } ") ;
614
648
}
615
649
616
- long argCount = Runtime . PyTuple_Size ( args ) ;
617
- value . Append ( ": (" ) ;
618
- for ( long argIndex = 0 ; argIndex < argCount ; argIndex ++ ) {
619
- var arg = Runtime . PyTuple_GetItem ( args , argIndex ) ;
620
- if ( arg != IntPtr . Zero ) {
621
- var type = Runtime . PyObject_Type ( arg ) ;
622
- if ( type != IntPtr . Zero ) {
623
- try {
624
- var description = Runtime . PyObject_Unicode ( type ) ;
625
- if ( description != IntPtr . Zero ) {
626
- value . Append ( Runtime . GetManagedString ( description ) ) ;
627
- Runtime . XDecref ( description ) ;
628
- }
629
- } finally {
630
- Runtime . XDecref ( type ) ;
631
- }
632
- }
633
- }
634
-
635
- if ( argIndex + 1 < argCount )
636
- value . Append ( ", " ) ;
637
- }
638
- value . Append ( ')' ) ;
650
+ value . Append ( ": " ) ;
651
+ AppendArgumentTypes ( to : value , args ) ;
639
652
Exceptions . SetError ( Exceptions . TypeError , value . ToString ( ) ) ;
640
653
return IntPtr . Zero ;
641
654
}
0 commit comments