Support ByRef arguments in event handlers#1364
Conversation
|
This still does not allow python to change the value under the memory location passed by reference? Ideally, a special Python |
Sorry, something went wrong.
|
Perhaps, but your scenario is not the one in #1355 . This PR at least prevents crashes. |
Sorry, something went wrong.
|
Since you can't override Python assignment operator, this fix is fundamentally incompatible with the proper solution with Even if we don't implement updating the value right now, to avoid making breaking changes later the value has to be wrapped into some Python object instance. E.g. in the linked issue the handler code should be def handleEventData(data):
print("=== event invoked. data: {} ===".format(data.Value)) # NOTE .Value |
Sorry, something went wrong.
|
When Python calls a .NET method with ref arguments, it returns a tuple of out/ref parameters, and if there's a return value it is the first in the tuple. See methodbinder.cs and stackoverflow. Therefore the "proper solution" is for |
Sorry, something went wrong.
|
Good point. Still for forward compatibility we must at least check Python returns a tuple of the correct size, or better yet actually implement the marshaling of updated variables back to the event. |
Sorry, something went wrong.
…ers in Python, by returning the modified parameter values in a tuple. BREAKING: MethodBinder omits a void return type when returning a tuple of out parameters. DelegateManager unpacks a tuple of out parameters from Python (reversing the logic in MethodBinder) and sets the out parameters of the delegate.
|
So is this supposed to be released with 2.5.2? |
Sorry, something went wrong.
What does this implement/fix? Explain your changes.
When an event handler has a ByRef argument, extra logic is needed in DelegateManager.GetDispatcher or else the program will access invalid memory and crash.
Does this close any currently open issues?
#1355
Any other comments?
...
Checklist
Check all those that are applicable and complete.
AUTHORSCHANGELOG