- Notifications
You must be signed in to change notification settings - Fork750
Description
Environment
Computer 1:
- Pythonnet version: 2.3, installed via pip I think
- Python version: 2.7.12
- Operating System: Ubuntu 16.04.2
Computer 2:
- Pythonnet version: manual build on master from commitce14424 (currently 11 commits behind)
- Python version: 2.7.12
- Operating System: Ubuntu 16.04.2
Details
Description: Python calls .NET function which returns a List. Python then passes the return value, without modification, to a second .NET function which accepts a List. Computer 1 executes this code just fine. On Computer 2, there is no .NET function found that matches the arguments because the return value of the .NET function has been transformed into a Python list.
Python code:
import clrfrom MyDotNetProject import PythonInteropx = PythonInterop.GetDoubleList()PythonInterop.PrintDoubleList(x)
.NET code:
public class PythonInterop { public static List<Double> GetDoubleList() { var result = new List<Double>(); result.Add(1); result.Add(2); result.Add(3); return result; } public static void PrintDoubleList(List<Double> list) { Console.WriteLine("You list has " + list.Count + " elements"); } }
The Python code works fine on Computer 1. On Computer 2, the PrintDoubleList call produces
TypeError: No method matches given arguments
If I print type(x) in Python, Computer 1 gives me a .NET List type while Computer 2 gives me a Python list. I can print x.Count on Computer 1, but I get a missing attribute error on Computer 2.
If I build manually from the 2.3 tag, I get the same (good) behavior as on Computer 1.
It seems that some feature has been partially added to automatically convert .NET objects into Python objects when possible. I suppose this is ok (though I would prefer that not happen because I don't want the mandatory performance hit of converting even when I don't want to convert), but if that's the intention, theremust be automatic conversion of Python objects to .NET objects also. One without the other is a critical bug.