You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Must explicitly convert IntEnum to int to use equality comparison #1848
Operating System: Windows 10 Pro - 21H2 - 19044.1766
.NET Runtime: Unity/Mono
Details
When trying to compare the equality of Python IntEnum instances from C#, they must be explicitly converted to an int.
# in my_module.py fileclassMyEnum(enum.IntEnum):
OK=1ERROR=2defget_status():
returnMyEnum.OK
No crash.
PythonRunner.EnsureInitialized();using(Py.GIL()){// Import our moduledynamicmy_module=Py.Import("my_module");dynamicMyEnum=my_module.MyEnum;// Call the Python func on C# sidedynamicstatus=my_module.get_status();if((int)status==(int)MyEnum.OK)// <-- have to convert to intif(status==MyEnum.OK)// when not converting to int, they are not evaluated as equal (no crash)}
Activity
filmor commentedon Jun 30, 2022
Thank you for the complete report. I'll have a look into this once I'm back at a proper computer in about a week.
implemented dynamic equality and inequality for PyObject instances
implemented dynamic equality and inequality for PyObject instances
implemented dynamic equality and inequality for PyObject instances
implemented dynamic equality and inequality for PyObject instances
implemented dynamic equality and inequality for PyObject instances