-
Notifications
You must be signed in to change notification settings - Fork 748
Disambiguating an overloaded method with multiple parameters #1099
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Version 2.3.0 is outdated, can you reproduce the issue with 2.4 or the current master? |
Hi @filmor, thanks for the quick reply. I can confirm It does also happen in 2.4. I was unable to try with the current master because installation fails. I'm running
If you feel it's important to try in the current master I can look into the error and keep trying. I've updated the first post with a few more details. |
Hi, I believe I've encountered the same problem (using pythonet 2.4.0 / python 2.7 / win10). If it help, I was able to create a unit test using master branch to reproduce/demonstrate : In short :
|
Hi, I can confirm the (mis)behavior as stated by @thegrima and I believe the issue still exists in pythonet 2.5.1 / python 2.7 / win10. I am not sure whether this is really solved by #1213 (for 2.5.2) as mentioned in #1211. NET function overloading should really work, this is a basic principle for OOP. I already tried to give the signature when calling e.g., Does anyone know a workaround? |
If you are not sure whether this is fixed, please try it out.
This is a non-trivial problem and has nothing to do with basic principles. Python doesn't have a concept of overloading a function, not even with regard to the argument count, so all of this behaviour has to be manually implemented in this library. Contributions of test-cases and possible fixes are always welcome. |
Sorry, I did not intended to complain in any way. You are right, my word were too harsh. I understand that this is non-trivial. I checked with |
Only way we found is to duplicate all C# methods to have all possible combination of arguments with double/int (our use case). |
I played around the last couple of hours. When I call with explicit System based parameters from python to C# overload matching seems to work for 2.5.1 - a possible workaround (?):
|
The code that opened this issue fails because The issue described by thegrima is a different problem, related to #1040. thegrima's code does rely on overloading because if |
Thanks for your feedback. |
Only if you want to. By leaving a message there, you will be notified of new activity on that issue. But you could also just subscribe to the issue. |
BTW, I think we should disable implicit .NET enum <-> Python |
I agree by default with all automatic conversion removals apart from int, float, str, and bool. When doing so, we should probably collect sensible codecs in a ticket to include them as optional features (e.g. a backwards-compatible enum->int codec or a new one that maps |
This should now be fixed in 3.0 |
Environment
Details
The C# side
On the python side, I began with this code
This fails with
TypeError: No method matches given arguments for Add
. I've tried what seemed to solve it for #935 but get the same resultsThis fails with
TypeError: No match found for given type params
print(obj.MyDictionary.Add.__overloads__)
isUPDATE
Running this code alone actually works,
add
shows as a bound method in the debugger:However, attempting to call the function always fails. I've attempted passing System.byte and 0, instead of the enum, but none of them work.
The text was updated successfully, but these errors were encountered: