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

Move the IEnumerable converter in Converter.ToPython to the TypeCode.Object case. by patstew · Pull Request #3 · fkarb/pythonnet · GitHub

Repository navigation

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .cs  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
21 changes: 11 additions & 10 deletions src/runtime/converter.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@ internal static IntPtr ToPython(Object value, Type type) {
}
}

if (value is IEnumerable) {
using (var resultlist = new PyList()) {
foreach (object o in (IEnumerable)value) {
using (var p = new PyObject(ToPython(o, o.GetType())))
resultlist.Append(p);
}
Runtime.Incref(resultlist.Handle);
return resultlist.Handle;
}
}

return result;

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

default:
if (value is IEnumerable) {
using (var resultlist = new PyList()) {
foreach (object o in (IEnumerable)value) {
using (var p = new PyObject(ToPython(o, o.GetType())))
resultlist.Append(p);
}
Runtime.Incref(resultlist.Handle);
return resultlist.Handle;
}
}
result = CLRObject.GetInstHandle(value, type);
return result;
}
Expand Down

Back | FazBrowse Home | New Git URL