- Notifications
You must be signed in to change notification settings - Fork768
C#: in and ref parameters misinterpreted as out parameters#2630
-
Hi, I'm trying to use pythonnet with a large C# codebase to expose it to python. I'm running into issues with methods that take Methods that take Here's a minimal repro: usingPython.Runtime;namespacetestpy;publicclassMyClass(floatvalue){privatefloat_value=value;publicstaticMyClassoperator+(inMyClassv0,inMyClassv1){returnnewMyClass(v0._value+v1._value);}publicMyClassMyFunc(inMyClassother){returnnewMyClass(_value+other._value);}}classProgram{staticvoidMain(string[]args){Runtime.PythonDLL="python311.dll";PythonEngine.Initialize();using(Py.GIL()){dynamicpy=Py.CreateScope();py.Set("m1",newMyClass(1).ToPython());py.Set("m2",newMyClass(2).ToPython());stringcode=@"v1 = m1.MyFunc(m2)print(v1) # prints (<testpy.MyClass object at 0x00000000068FB780>, <testpy.MyClass object at 0x00000000068FB7C0>)v2 = m1 + m2 # exception";py.Exec(code);}}}
As I understand it, this happens because NOTE: I see in debug thatthis code doesn't care about |
BetaWas this translation helpful?Give feedback.