8000 Allow conversion of UInt64 based enums · pythonnet/pythonnet@7d6e27a · GitHub
[go: up one dir, main page]

Skip to content

Commit 7d6e27a

Browse files
committed
Allow conversion of UInt64 based enums
1 parent 4f070f2 commit 7d6e27a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/runtime/Codecs/EnumPyIntCodec.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,14 @@ public bool TryDecode<T>(PyObject pyObj, out T? value)
5353
var enumType = value.GetType();
5454
if (!enumType.IsEnum) return null;
5555

56-
return new PyInt(Convert.ToInt64(value));
56+
try
57+
{
58+
return new PyInt(Convert.ToInt64(value));
59+
}
60+
catch (OverflowException)
61+
{
62+
return new PyInt(Convert.ToUInt64(value));
63+
}
5764
}
5865

5966
private EnumPyIntCodec() { }

0 commit comments

Comments
 (0)
0