Skip to content

Pythonnet 3.0 Enums with integer #1971

@hamzaselmancelik

Description

@hamzaselmancelik

Environment

  • Pythonnet version: 3.0
  • Python version: 3.8
  • Operating System: Windows

Details

  • I was using Pythonnet 2.5.2, and I have a C# Languages Enum. I have a HowManyLanguagesDoYouSpeak method on C#:
    public int HowManyLanguagesDoYouSpeak(Languages languages)
    {
    return Enum.GetValues(typeof(Languages)).Cast()
    .Where(lang => Languages.NoLanguage != lang)
    .Where(lang => (languages & lang).Equals(lang)).Count();
    }

    I was calling this method python with pythonnet with:
    result = self.cs_object.HowManyLanguagesDoYouSpeak(5)

    It used to work just fine with pythonnet 2.5.2. Now that I updated my pythonnet into 3.0. It does not work anymore. I get an error

    image

    I think this needs to be solved on pythonnet 3.0

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