Skip to content

cannot get anymore int of enumclass (alpha2) #1810

Closed

Description

@maxcapodi78

Environment

  • Pythonnet version: 3.0.0dev
  • Python version: 3.9
  • Operating System: Windows
  • .NET Runtime:

Details

  • Describe what you were trying to get done.

In v2.5.2 I'm able to get a C# enum and get the int value. In alpha 2 it seems that the full enum class is returned but the int command is not working. In 3.0.0dev it makes crashing the Debugger.

  • What commands did you run to trigger this issue? If you can provide a
    Minimal, Complete, and Verifiable example
    this will help us understand the issue.
    image

  • If there was a crash, please include the traceback here.

    Out[13]: <bound method 'int'>

Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at Python.Runtime.Runtime.PyLong_FromLongLong(Int64 value)
at Python.Runtime.PyInt..ctor(Int64 value)
at Python.Runtime.EnumOps`1.int(T value)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Python.Runtime.MethodBinder.Invoke(BorrowedReference inst, BorrowedReference args, BorrowedReference kw, MethodBase info, MethodBase[] methodinfo)
at Python.Runtime.MethodObject.Invoke(BorrowedReference target, BorrowedReference args, BorrowedReference kw, MethodBase info)
at Python.Runtime.MethodBinding.tp_call(BorrowedReference ob, BorrowedReference args, BorrowedReference kw)

Process finished with exit code -532462766

Activity

  1. filmor commented on Jun 8, 2022

    @filmor
    Member

    I can't reproduce this, you have given almost no code here. Does the code run outside of the debugger? Please provide a Minimal, Complete and Verifiable example.

  2. maxcapodi78 commented on Jun 8, 2022

    @maxcapodi78
    Author

    Hi @filmor I don't know how to create an example for you since I obtain it from My C# API that returns an enum on the following call:
    self.edbcomponent.GetComponentType()

    I have the full enum in it including .value__ property (not .value). When I do the int of that enum it crashes and and stops to work. It fails also in running mode.
    This is the content of the enum
    image
    the command should return 1 (the content of value__)

  3. filmor commented on Jun 8, 2022

    @filmor
    Member

    I am sorry, I can't and won't do remote debugging. Please provide a complete example that reproduces the issue that I can run on my machine.

  4. maxcapodi78 commented on Jun 8, 2022

    @maxcapodi78
    Author

    Taken from your Unit Test:

    from System import DayOfWeek
    int(DayOfWeek.Sunday)

  5. filmor commented on Jun 8, 2022

    @filmor
    Member

    Odd that this works in the unit test itself, I'll have a look.

  6. maxcapodi78 commented on Jun 8, 2022

    @maxcapodi78
    Author

    @filmor I've taken from UT the enum to test but I noticed that you don't run a test on an enum value.
    So you can debug and add that as additional test for future reference

  7. lostmsu commented on Jun 8, 2022

    @lostmsu
    Member

    The exception looks like GIL is being released somewhere.

  8. filmor commented on Jun 13, 2022

    @filmor
    Member

    @maxcapodi78 This should be fixed on the current master, if not, please reopen :)

  9. maxcapodi78 commented on Jun 13, 2022

    @maxcapodi78
    Author

    @filmor I've tested the latest main and it works pretty well. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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