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
Next Next commit
Fix enum codec
A boxed enum value can't be casted directly to an integer, but using `System.Convert`
functions instead works fine.
  • Loading branch information
filmor committed May 4, 2022
commit df3b569eb1f8da0524d1322139aab520918f2a1b
9 changes: 1 addition & 8 deletions src/runtime/Codecs/EnumPyIntCodec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,7 @@ public bool TryDecode<T>(PyObject pyObj, out T? value)
var enumType = value.GetType();
if (!enumType.IsEnum) return null;

try
{
return new PyInt((long)value);
}
catch (InvalidCastException)
{
return new PyInt((ulong)value);
}
return new PyInt(Convert.ToInt64(value));
}

private EnumPyIntCodec() { }
Expand Down