Converting Callable Python to Dotnet Delegate#2015
Conversation
|
Hello friends. I'd love to get a review on this to improve and fix. I'll then create the necessary tests and will mark this as final |
|
Self notes:
|
|
@filmor Sorry to tag you directly here but all tests are failing on this one commit I added to the master branch. They are related to this analyzer Not sure where the problem is |
No they are not. That message is just a warning. |
|
Looks good to me. @lostmsu? |
| { | ||
| if (Runtime.PyTuple_Size(args) != 1) | ||
| { | ||
| throw new Exception("Event handler methods only accept one Delegate argument"); |
There was a problem hiding this comment.
This must be generating TypeError
| throw new ArgumentException("We should never receive instances of other managed types"); | ||
| } | ||
|
|
||
| // NOTE: generate a delegate to cast a python callable into a System.Delegate |
There was a problem hiding this comment.
This should either be part of ToPrimitive, or at very least moved down so that codecs could override this behavior.
Also @filmor even if this is corrected this is a breaking change as it might fail or change overload resolution.
There was a problem hiding this comment.
Can you give an example that worked before and doesn't with this merged? I don't get how this would change the overload resolution in a breaking fashion.
There was a problem hiding this comment.
void Foo(PyObject x) vs void Foo(System.Action x) previously would unambiguously resolve to the first variant. With this change it will either fail due to non-unique resolution or attempt to prioritize, which might or might not result in the second one being selected.
We previously made similar and even more drastic changes in 2.x branch. Question is do we want to continue in 3.x?
This could be put into a decoder.
It is actually a questionable default, considering what stuff can turn out to be callable in popular Python libraries.
What does this implement/fix? Explain your changes.
When a dotnet method requries a delegate as a parameter, pythonnet fails to convert a python function into a dotnet delegate
Does this close any currently open issues?
Not that I know of
Any other comments?
No
Checklist
Check all those that are applicable and complete.
AUTHORSCHANGELOG