8000 Method overload with decimal parameter accepts non-decimal numbers by AlexCatarino · Pull Request #10 · QuantConnect/pythonnet · GitHub
[go: up one dir, main page]

Skip to content

Method overload with decimal parameter accepts non-decimal numbers #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Apr 2, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Implements Nullable support
  • Loading branch information
AlexCatarino committed Mar 12, 2018
commit 391c0378e2e474724f7fc2dd979f323fd2b963ff
8 changes: 7 additions & 1 deletion src/runtime/converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,12 @@ internal static bool ToManagedValue(IntPtr value, Type obType,
return false;
}

var underlyingType = Nullable.GetUnderlyingType(obType);
if (underlyingType != null)
{
return ToManagedValue(value, underlyingType, out result, setError);
}

return ToPrimitive(value, obType, out result, setError);
}

Expand Down Expand Up @@ -974,7 +980,7 @@ private static bool ToArray(IntPtr value, Type obType, out object result, bool s
int size = Runtime.PySequence_Size(value);
result = null;

if (size < 0)
if (size < 0 || elementType.IsGenericType)
{
if (setError)
{
Expand Down
8 changes: 7 additions & 1 deletion src/runtime/methodbinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,14 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw, MethodBase info, Meth
}
if (!typematch)
{
// this takes care of nullables
var underlyingType = Nullable.GetUnderlyingType(pi[n].ParameterType);
if (underlyingType == null)
{
underlyingType = pi[n].ParameterType;
}
// this takes care of enum values
TypeCode argtypecode = Type.GetTypeCode(pi[n].ParameterType);
TypeCode argtypecode = Type.GetTypeCode(underlyingType);
TypeCode paramtypecode = Type.GetTypeCode(clrtype);
if (argtypecode == paramtypecode)
{
Expand Down
0