Skip to content
Prev Previous commit
Next Next commit
Convert error for UInt32
  • Loading branch information
amos402 committed Jul 29, 2020
commit 97f00095362b006f61a20ffc019f005a87b12935
10 changes: 6 additions & 4 deletions src/runtime/converter.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Security;
using System.ComponentModel;
using System.Linq.Expressions;

namespace Python.Runtime
{
Expand Down Expand Up @@ -666,6 +664,10 @@ private static bool ToPrimitive(IntPtr value, Type obType, out object result, bo
else
{
ulong num = Runtime.PyLong_AsUnsignedLong64(op);
if (num == ulong.MaxValue && Exceptions.ErrorOccurred())
{
goto convert_error;
}
try
{
result = Convert.ToUInt32(num);
Expand All @@ -692,7 +694,7 @@ private static bool ToPrimitive(IntPtr value, Type obType, out object result, bo
goto convert_error;
}
}
ulong num = Runtime.PyLong_AsUnsignedLongLong(value);
ulong num = Runtime.PyLong_AsUnsignedLongLong(op);
if (num == ulong.MaxValue && Exceptions.ErrorOccurred())
{
goto overflow;
Expand Down