Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Allow conversion of UInt64 based enums
  • Loading branch information
filmor committed May 4, 2022
commit 7d6e27a23ec88138ada829f50e473cea394df189
9 changes: 8 additions & 1 deletion src/runtime/Codecs/EnumPyIntCodec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,14 @@ public bool TryDecode<T>(PyObject pyObj, out T? value)
var enumType = value.GetType();
if (!enumType.IsEnum) return null;

return new PyInt(Convert.ToInt64(value));
try
{
return new PyInt(Convert.ToInt64(value));
}
catch (OverflowException)
{
return new PyInt(Convert.ToUInt64(value));
}
}

private EnumPyIntCodec() { }
Expand Down