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

Enums now don't convert to UInt32 in 3.0.0rc4 #1913

Closed
@Pcres91

Description

@Pcres91

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp