🌐 AI搜索 & 代理 主页
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
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);
ulong num = Runtime.PyLong_AsUnsignedLongLong(value);
if (num == ulong.MaxValue && Exceptions.ErrorOccurred())
{
goto overflow;
goto convert_error;
}
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):
with pytest.raises(TypeError):
ConversionTest().UInt64Field = 0.5

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

with pytest.raises(TypeError):
Expand Down