◐ Shell
reader mode source ↗
Skip to content
Merged
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
13 changes: 2 additions & 11 deletions src/runtime/converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -698,19 +698,10 @@ private static bool ToPrimitive(IntPtr value, Type obType, out object result, bo

case TypeCode.UInt64:
{
op = value;
if (Runtime.PyObject_TYPE(value) != Runtime.PyLongType)
{
op = Runtime.PyNumber_Long(value);
if (op == IntPtr.Zero)
{
goto convert_error;
}
}
ulong num = Runtime.PyLong_AsUnsignedLongLong(op);
if (num == ulong.MaxValue && Exceptions.ErrorOccurred())
{
goto overflow;
}
result = num;
return true;
Expand Down
5 changes: 4 additions & 1 deletion src/tests/test_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,10 @@ def test_uint64_conversion():
ob.UInt64Field = System.UInt64(0)
assert ob.UInt64Field == 0

with pytest.raises(ValueError):
ConversionTest().UInt64Field = "spam"

with pytest.raises(TypeError):
Expand Down
Toggle all file notes Toggle all file annotations