[Python.NET] patch to allow for null array references in method calls

Rodrigo B. de Oliveira rbo at acm.org
Fri Jan 2 11:39:11 EST 2004


I've ran into a problem with Converter.ToManaged when trying to call
ILGenerator.EmitCall. EmitCall demands its last parameter (of type
System.Type[]) to be null for non-varargs methods but Converter.ToManager
wouldn't convert None to a null reference.

My solution was simply to move the explicit check for Runtime.PyNone to the
line 186, before the IsArray check:

<snip>

if (value == Runtime.PyNone && !obType.IsValueType) {
  result = null;
  return true;
     }

     if (obType.IsArray) {
  return ToArray(value, obType, out result, setError);
     }

     if (obType.IsEnum) {
  return ToEnum(value, obType, out result, setError);
     }
</snip>

Is this correct?

Best wishes,
Rodrigo




More information about the PythonDotNet mailing list