@@ -245,7 +245,7 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw,
245245 else {
246246 _methods = GetMethods ( ) ;
247247 }
248- Type type ;
248+ Type clrtype ;
249249 for ( int i = 0 ; i < _methods . Length ; i ++ ) {
250250 MethodBase mi = _methods [ i ] ;
251251
@@ -295,34 +295,52 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw,
295295 // this logic below handles cases when multiple overloading methods
296296 // are ambiguous, hence comparison between Python and CLR types
297297 // is necessary
298- type = null ;
299-
300- if ( _methods . Length > 1 ) {
301- IntPtr pyoptype = IntPtr . Zero ;
298+ clrtype = null ;
299+ IntPtr pyoptype ;
300+ if ( _methods . Length > 1 ) {
301+ pyoptype = IntPtr . Zero ;
302302 pyoptype = Runtime . PyObject_Type ( op ) ;
303303 Exceptions . Clear ( ) ;
304- if ( pyoptype != IntPtr . Zero ) { }
305- type = Converter . GetTypeByAlias ( pyoptype ) ;
306- Runtime . Decref ( pyoptype ) ;
304+ if ( pyoptype != IntPtr . Zero ) {
305+ clrtype = Converter . GetTypeByAlias ( pyoptype ) ;
307306 }
307+ Runtime . Decref ( pyoptype ) ;
308+ }
308309
309310
310- if ( type != null ) {
311- if ( pi [ n ] . ParameterType != type ) {
312- margs = null ;
313- break ;
311+ if ( clrtype != null ) {
312+ if ( pi [ n ] . ParameterType != clrtype ) {
313+ IntPtr pytype = Converter . GetPythonTypeByAlias ( pi [ n ] . ParameterType ) ;
314+ pyoptype = Runtime . PyObject_Type ( op ) ;
315+ Exceptions . Clear ( ) ;
316+ if ( pyoptype != IntPtr . Zero ) {
317+ if ( pytype != pyoptype ) {
318+ Runtime . Decref ( pyoptype ) ;
319+ margs = null ;
320+ break ;
321+ }
322+ else {
323+ clrtype = pi [ n ] . ParameterType ;
324+ }
325+ }
326+ else {
327+ Runtime . Decref ( pyoptype ) ;
328+ margs = null ;
329+ break ;
330+ }
331+ Runtime . Decref ( pyoptype ) ;
314332 }
315333 }
316334 else {
317- type = pi [ n ] . ParameterType ;
335+ clrtype = pi [ n ] . ParameterType ;
318336 }
319337
320- if ( pi [ n ] . IsOut || type . IsByRef )
338+ if ( pi [ n ] . IsOut || clrtype . IsByRef )
321339 {
322340 outs ++ ;
323341 }
324342
325- if ( ! Converter . ToManaged ( op , type , out arg , false ) )
343+ if ( ! Converter . ToManaged ( op , clrtype , out arg , false ) )
326344 {
327345 Exceptions . Clear ( ) ;
328346 margs = null ;
0 commit comments