- Notifications
You must be signed in to change notification settings - Fork750
Allow conversion of number to enum type when underlying type is assignable#1179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
In .NET you can do the following:```enum FooEnum {One = 1,Three = 3,Four = 4,}FooEnum x = (FooEnum)2;```This patch allows this from Python code as well.
@slide in .NET you can't just assign a numeric value to an enum. You have to make an explicit cast for a good reason. The most pythonic way I see this could work is |
That's true, it does require the typecast. This only allows assignment/coercion when the underlying type is assignable, is that still too lenient? |
lostmsu commentedJul 6, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@slide oh, I checked the code of I actually think Python.NET should have required an explicit cast from the beginning, and should not have converted enum values to Python Summoning@filmor into conversation. |
Ok, thanks, I'll see if I can work on something like that. |
Uh oh!
There was an error while loading.Please reload this page.
What does this implement/fix? Explain your changes.
In .NET you can do the following:
This patch allows this from Python code as well.
Does this close any currently open issues?
Possibly#935
Any other comments?
I would definitely like eyes on this, I am possibly missing something :-)
Checklist
Check all those that are applicable and complete.
AUTHORS
CHANGELOG