10000 don't convert IEnumerables to python lists unless nothing else matches · yagweb/pythonnet@471673a · GitHub
[go: up one dir, main page]

Skip to content

Commit 471673a

Browse files
committed
don't convert IEnumerables to python lists unless nothing else matches
(strings shouldn't be converted to lists, for example)
1 parent f3ff88d commit 471673a

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

pythonnet/src/runtime/converter.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,16 +110,6 @@ internal static IntPtr ToPython(Object value, Type type) {
110110
return ClassDerivedObject.ToPython(pyderived);
111111
}
112112

113-
if (value is IEnumerable)
114-
{
115-
var resultlist = new PyList();
116-
foreach (object o in (IEnumerable)value)
117-
{
118-
resultlist.Append(new PyObject(ToPython(o, o.GetType())));
119-
}
120-
return resultlist.Handle;
121-
}
122-
123113
// hmm - from Python, we almost never care what the declared
124114
// type is. we'd rather have the object bound to the actual
125115
// implementing class.
@@ -194,6 +184,15 @@ internal static IntPtr ToPython(Object value, Type type) {
194184
return Runtime.PyLong_FromUnsignedLongLong((ulong)value);
195185

196186
default:
187+
if (value is IEnumerable)
188+
{
189+
var resultlist = new PyList();
190+
foreach (object o in (IEnumerable)value)
191+
{
192+
resultlist.Append(new PyObject(ToPython(o, o.GetType())));
193+
}
194+
return resultlist.Handle;
195+
}
197196
result = CLRObject.GetInstHandle(value, type);
198197
return result;
199198
}

0 commit comments

Comments
 (0)
0