Skip to content

Commit e9712b4

Browse files
committed
when converting to object, wrap values of unknown type into PyObject instead of failing
This enables overload resolution with object parameters to behave the same way PyObject parameters behave - e.g. allow any Python object to be passed as PyObject as fallback. Resolves #811
1 parent fefe3de commit e9712b4

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/runtime/converter.cs

+3-6
Original file line numberDiff line numberDiff line change
@@ -382,12 +382,9 @@ internal static bool ToManagedValue(IntPtr value, Type obType,
382382
return ToArray(value, typeof(object[]), out result, setError);
383383
}
384384

385-
if (setError)
386-
{
387-
Exceptions.SetError(Exceptions.TypeError, "value cannot be converted to Object");
388-
}
389-
390-
return false;
385+
Runtime.XIncref(value); // PyObject() assumes ownership
386+
result = new PyObject(value);
387+
return true;
391388
}
392389

393390
// Conversion to 'Type' is done using the same mappings as above for objects.

0 commit comments

Comments
 (0)