I have the following method defined in my application that I am trying to call from Python using PythonNET
Snippet public IEnumerable<byte> ReadBuffer(ulong address, int size, out int readCount) The address can be anything in the range of 0x0_0000_0000 - 0x1_XXXX_XXXX, when I call this using a value that is less than 0x1_0000_0000 (e.g., 0x0_01d00_0000) I get an error that the value an Int32 when a UInt64 is expected, so I created an override that takes an Int32 as the first parameter and the function works when using values less than 0x1_0000_0000, so far so good. However, when I try and call the function with an address >= 0x1_0000_0000 I get the following exception. System.AggregateException: One or more errors occurred. ---> System.ArgumentException: Expected UInt64, got Int32 in method System.Collections.Generic.IEnumerab le`1[System.Byte] ReadBuffer(UInt64, Int32, Int32 ByRef) ---> Python.Runtime.PythonException: Expected UInt64, got Int32 --- End of inner exception stack trace --- --- End of inner exception stack trace --- ---> (Inner Exception #0) System.ArgumentException: Expected UInt64, got Int32 in method System.Collections.Generic.IEnumerable`1[System.Byte] ReadBuffer(UInt64 , Int32, Int32 ByRef) ---> Python.Runtime.PythonException: Expected UInt64, got Int32 --- End of inner exception stack trace ---<--- ---> (Inner Exception #1) System.ArgumentException: value too large to convert in method System.Collections.Generic.IEnumerable`1[System.Byte] ReadBuffer(Int32, Int32, Int32 ByRef) ---> Python.Runtime.PythonException: value too large to convert --- End of inner exception stack trace ---<--- It seems like the checks in converter.cs will choose Int32 even if the value is longer that 32-bits (since PyInt is also true for larger than 32-bit values). Snippet if (value == Runtime.PyIntType){ result = int32Type; return true;} if (value == Runtime.PyLongType){ result = int64Type; return true;} So, I am confused how I can get the correct method resolution and the correct type. Can anyone shed any light on this? Regards, Alex -- Website: http://earl-of-code.com
_______________________________________________ PythonNet mailing list -- pythonnet@python.org To unsubscribe send an email to pythonnet-le...@python.org https://mail.python.org/mailman3/lists/pythonnet.python.org/ Member address: arch...@mail-archive.com