FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Move the IEnumerable converter in Converter.ToPython to the TypeCode.… · patstew/pythonnet@7b0c87f · GitHub

Repository navigation

Commit 7b0c87f

Browse files
committed
Move the IEnumerable converter in Converter.ToPython to the TypeCode.Object case.
1 parent 41ff7cb commit 7b0c87f

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

‎src/runtime/converter.cs‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,17 @@ internal static IntPtr ToPython(Object value, Type type) {
122122
}
123123
}
124124

125+
if (value is IEnumerable) {
126+
using (var resultlist = new PyList()) {
127+
foreach (object o in (IEnumerable)value) {
128+
using (var p = new PyObject(ToPython(o, o.GetType())))
129+
resultlist.Append(p);
130+
}
131+
Runtime.Incref(resultlist.Handle);
132+
return resultlist.Handle;
133+
}
134+
}
135+
125136
return result;
126137

127138
case TypeCode.String:
@@ -174,16 +185,6 @@ internal static IntPtr ToPython(Object value, Type type) {
174185
return Runtime.PyLong_FromUnsignedLongLong((ulong)value);
175186

176187
default:
177-
if (value is IEnumerable) {
178-
using (var resultlist = new PyList()) {
179-
foreach (object o in (IEnumerable)value) {
180-
using (var p = new PyObject(ToPython(o, o.GetType())))
181-
resultlist.Append(p);
182-
}
183-
Runtime.Incref(resultlist.Handle);
184-
return resultlist.Handle;
185-
}
186-
}
187188
result = CLRObject.GetInstHandle(value, type);
188189
return result;
189190
}

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL