The attached patch improves support for converting managed values (reference or boxed values) to the corresponding Python types.
This support had previously been partly implemented in Converter.ToPython() but it was not exposed in the public interface of PyObject (if I'm not mistaken), which made it hard for me to call Python functions from managed code in an embedding scenario. My patch makes the following changes:
Being not very familiar with the Python for .NET codebase, I didn't have the heart to build my array support directly into Converter.ToPython(). However I'd be happy if the array handling code could go to Converter.ToPython() in order to avoid having two similarly-named functions (.ToPython() and .ToPythonValue()) which differ in a non-obvious way, so if that is considered appropriate, please move it there.