Skip to content

Commit

Permalink
Merge branch 'pr/floatToInt' into rhino-8.x
Browse files Browse the repository at this point in the history
  • Loading branch information
eirannejad committed Dec 20, 2023
2 parents a99a258 + d1afda6 commit a650c89
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/runtime/Converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,18 @@ internal static bool ToPrimitive(BorrowedReference value, Type obType, out objec

case TypeCode.Int32:
{
// lets allow sending python floats into dotnet integers
nint num;
if (Runtime.PyFloat_Check(value))
{
num = (int)Runtime.PyFloat_AsDouble(value);
}
// Python3 always use PyLong API
nint num = Runtime.PyLong_AsSignedSize_t(value);
else
{
num = Runtime.PyLong_AsSignedSize_t(value);
}

if (num == -1 && Exceptions.ErrorOccurred())
{
goto convert_error;
Expand Down

0 comments on commit a650c89

Please sign in to comment.