Hi. In response to this query I had one of my colleagues debug an issue, and he found that PythonNet does not correctly generate code when calling into a function with a "ref ValueType" parameter. In his words:
The problem is here in the PythonNet code:
for (var i = 0; i < parameters.Length; ++i)
{
il.Emit(OpCodes.Ldloc_0);
il.Emit(OpCodes.Ldc_I4, i);
il.Emit(OpCodes.Ldarg, i + 1);
if (parameterTypes[i].IsValueType)
{
il.Emit(OpCodes.Box, parameterTypes[i]);
}
il.Emit(OpCodes.Stelem, typeof(object));
}
The code is trying to store all of the incoming arguments in an array of type Object[]. The cases are:
The code above handles #1 and #2, but doesn’t handle #3.
Hopefully that's enough for someone to create or contribute a fix.
Thank you very much for the detailed analysis :)
A hard crash is of course not acceptable, so we'll need to fix this soon. I'll see if I understand enough of this to do something about the issue.
@filmor I don't know the status of fiscal sponsorship for Python.net, but if this is a problem where a fix can be expedited by throwing money at the problem, I may be in a position to supply that money.
The status of fiscal sponsorship for Python.NET is that there is none. The main issue with throwing money at the problem is finding someone to throw money at. It's not like we have a wealth of programmers with a lot of free time eager to work on problems that are not necessarily their own here.
@freakboy3742 I am sure if you list a bounty here somebody may pick it up.
I have no idea what amount of money would get this job done; if you're interested in doing this as work-for-hire, get in touch.