- Notifications
You must be signed in to change notification settings - Fork749
Closed
Description
Environment
- Pythonnet version: 3.0.0rc4
- Python version: 3.9 64-bit
- Operating System: Windows 10
- .NET Runtime: .NET Framework 4.8.4510.0
Details
- Describe what you were trying to get done.
I am trying passing my library's enum into a function that takes in a UInt32. Previously on Pythonnet 2.5, this conversion was done automatically. Now, I have to useSystem.Convert.ToUInt32(myenum.value)
for conversion. Even tryingUInt32(myenum.value)
fails.
Is this expected behaviour? I've also noticed that printing the enumerated value now prints the name, while previously it printed the value. Is this to make it more inline with what's expected in C#? I'd still expect the UInt32 conversion to work.
clr.AddReference("MyLibrary")fromMyLibraryimporteCompatibleVersion,MyClassmylib=MyClass()mylib.CheckCompatibility(eCompatibleVersion.BuildVersion)
Error received:
Python.Runtime.PythonException: MyLibrary.eCompatibleVersion value cannot be converted to System.UInt32The above exception was the direct cause of the following exception:System.ArgumentException: MyLibrary.eCompatibleVersion value cannot be converted to System.UInt32 in method Void CheckCompatibility(UInt32) ---> Python.Runtime.PythonException: MyLibrary.eCompatibleVersion value cannot be converted to System.UInt32 --- End of inner exception stack trace ---The above exception was the direct cause of the following exception:System.AggregateException: One or more errors occurred. ---> System.ArgumentException: MyLibrary.eCompatibleVersion value cannot be converted to System.UInt32 in method Void CheckCompatibility(UInt32) ---> Python.Runtime.PythonException: MyLibrary.eCompatibleVersion value cannot be converted to System.UInt32 --- End of inner exception stack trace --- --- End of inner exception stack trace ------> (Inner Exception #0) System.ArgumentException: MyLibrary.eCompatibleVersion value cannot be converted to System.UInt32 in method Void CheckCompatibility(UInt32) ---> Python.Runtime.PythonException: MyLibrary.eCompatibleVersion value cannot be converted to System.UInt32 --- End of inner exception stack trace ---<---The above exception was the direct cause of the following exception:Traceback (most recent call last): File "***", line 2, in <module> import load_library File "***", line 14, in <module> mylib.CheckCompatibility(eCompatibleVersion.BuildVersion)TypeError: No method matches given arguments for IMyClass.CheckCompatibility: (<class 'MyLibrary.eCompatibleVersion'>)
Metadata
Metadata
Assignees
Labels
No labels