question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cannot get anymore int of enumclass (alpha2)

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
maxcapodi78commented, Jun 8, 2022

Taken from your Unit Test:

from System import DayOfWeek int(DayOfWeek.Sunday)

0reactions
maxcapodi78commented, Jun 13, 2022

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

why can enum class values of type int not be used as int
You can't use c++11 scoped enums directly as int, but can cast it into int . Mainly because of type safety reason, unscoped...
Read more >
Why cast between two strongly typed C++11 enum classes ...
Hi,. C++11 strong enums ensure that we can not interchange 2 such enum classes as we can not interchange two independent structs.
Read more >
enum — Support for enumerations
Enum. Base class for creating enumerated constants. IntEnum ... Enum class decorator that ensures only one name is bound to any one value....
Read more >
Enumeration declaration
An enumeration is a distinct type whose value is restricted to a range of values (see below for details), which may include several ......
Read more >
Enumeration types - C# reference
An enumeration type (or enum type) is a value type defined by a set of named constants of the underlying integral numeric type....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found