diff --git a/src/runtime/converter.cs b/src/runtime/converter.cs index aa4ed6a80..62e091d31 100644 --- a/src/runtime/converter.cs +++ b/src/runtime/converter.cs @@ -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; diff --git a/src/tests/test_conversion.py b/src/tests/test_conversion.py index 6b152025d..3b290b947 100644 --- a/src/tests/test_conversion.py +++ b/src/tests/test_conversion.py @@ -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): pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy