Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdf3b569

Browse files
committed
Fix enum codec
A boxed enum value can't be casted directly to an integer, but using `System.Convert`functions instead works fine.
1 parent37f1235 commitdf3b569

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

‎src/runtime/Codecs/EnumPyIntCodec.cs

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

56-
try
57-
{
58-
returnnewPyInt((long)value);
59-
}
60-
catch(InvalidCastException)
61-
{
62-
returnnewPyInt((ulong)value);
63-
}
56+
returnnewPyInt(Convert.ToInt64(value));
6457
}
6558

6659
privateEnumPyIntCodec(){}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp