diff --git a/AUTHORS.md b/AUTHORS.md index 55aa69d11..f0b385fd0 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -12,6 +12,7 @@ ## Contributors +- Alexandre Catarino([@AlexCatarino](https://github.com/AlexCatarino)) - Arvid JB ([@ArvidJB](https://github.com/ArvidJB)) - Bradley Friedman ([@leith-bartrich](https://github.com/leith-bartrich)) - Callum Noble ([@callumnoble](https://github.com/callumnoble)) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96461ca68..34e932132 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ This document follows the conventions laid out in [Keep a CHANGELOG][]. - Fixed `clr.GetClrType` when iterating over `System` members (#607) - Fixed `LockRecursionException` when loading assemblies (#627) - Fixed errors breaking .NET Remoting on method invoke (#276) +- Fixed missing information on 'No method matches given arguments' by adding the method name ## [2.3.0][] - 2017-03-11 diff --git a/src/runtime/converter.cs b/src/runtime/converter.cs index 2762b77a5..c955a880f 100644 --- a/src/runtime/converter.cs +++ b/src/runtime/converter.cs @@ -106,6 +106,9 @@ internal static Type GetTypeByAlias(IntPtr op) if (op == Runtime.PyBoolType) return boolType; + if (op == Runtime.PyDecimalType) + return decimalType; + return null; } @@ -136,7 +139,7 @@ internal static IntPtr GetPythonTypeByAlias(Type op) return Runtime.PyBoolType; if (op == decimalType) - return Runtime.PyFloatType; + return Runtime.PyDecimalType; return IntPtr.Zero; } diff --git a/src/runtime/methodbinder.cs b/src/runtime/methodbinder.cs index 1f33447fd..94be7cc78 100644 --- a/src/runtime/methodbinder.cs +++ b/src/runtime/methodbinder.cs @@ -186,9 +186,16 @@ internal static int GetPrecedence(MethodBase mi) val += ArgPrecedence(pi[i].ParameterType); } + var info = mi as MethodInfo; + if (info != null) + { + val += ArgPrecedence(info.ReturnType); + val += mi.DeclaringType == mi.ReflectedType ? 0 : 3000; + } + return val; } - + /// /// Return a precedence value for a particular Type object. /// @@ -200,6 +207,11 @@ internal static int ArgPrecedence(Type t) return 3000; } + if (t.IsAssignableFrom(typeof(PyObject))) + { + return -1; + } + TypeCode tc = Type.GetTypeCode(t); // TODO: Clean up switch (tc) @@ -408,6 +420,12 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw, MethodBase info, Meth typematch = true; clrtype = pi[n].ParameterType; } + // accepts non-decimal numbers in decimal parameters + if (underlyingType == typeof(decimal)) + { + clrtype = pi[n].ParameterType; + typematch = Converter.ToManaged(op, clrtype, out arg, false); + } // this takes care of implicit conversions var opImplicit = pi[n].ParameterType.GetMethod("op_Implicit", new[] { clrtype }); if (opImplicit != null) diff --git a/src/runtime/runtime.cs b/src/runtime/runtime.cs index abd0661a4..01e405b6f 100644 --- a/src/runtime/runtime.cs +++ b/src/runtime/runtime.cs @@ -299,6 +299,14 @@ internal static void Initialize() PyFloatType = PyObject_Type(op); XDecref(op); + IntPtr decimalMod = PyImport_ImportModule("decimal"); + IntPtr decimalCtor = PyObject_GetAttrString(decimalMod, "Decimal"); + op = PyObject_CallObject(decimalCtor, IntPtr.Zero); + PyDecimalType = PyObject_Type(op); + XDecref(op); + XDecref(decimalMod); + XDecref(decimalCtor); + #if PYTHON3 PyClassType = IntPtr.Zero; PyInstanceType = IntPtr.Zero; @@ -392,6 +400,7 @@ internal static int AtExit() internal static IntPtr PyBoolType; internal static IntPtr PyNoneType; internal static IntPtr PyTypeType; + internal static IntPtr PyDecimalType; #if PYTHON3 internal static IntPtr PyBytesType;