Closed
Description
Environment
- Pythonnet version: 2.4.0
- Python version: 3.6.5
- Operating System: Centos 7 64bit
Details
- Creating UInt32 in python with a value greater than 0x7FFFFFFF in dotnetcore will cause an overflow error. This is due (seemingly) to the fact that .NET core clr will cast the
uint
to a signed long (64 bits in size on my system) before calling the PyLong_FromUsignedLong function. Using GDB and breaking before the errornous overflow we can examine the created PyLongObject:
The PyLongObject
given to C# by the python interpretter that can be converted to a uint
using PyLong_AsUnsignedLong
Using PyLong_FromUnsignedLong
on the resulting uint
gives this:
I have raised an issue on the coreclr project: Issue 26444
FYI changing the function definition from
internal static extern IntPtr PyLong_FromUnsignedLong(uint value);
to
internal static extern IntPtr PyLong_FromUnsignedLong(ulong value);
fixes the issue.
Metadata
Metadata
Assignees
Labels
No labels