Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit471673a

Browse files
committed
don't convert IEnumerables to python lists unless nothing else matches
(strings shouldn't be converted to lists, for example)
1 parentf3ff88d commit471673a

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
returnClassDerivedObject.ToPython(pyderived);
111111
}
112112

113-
if(valueisIEnumerable)
114-
{
115-
varresultlist=newPyList();
116-
foreach(objectoin(IEnumerable)value)
117-
{
118-
resultlist.Append(newPyObject(ToPython(o,o.GetType())));
119-
}
120-
returnresultlist.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
returnRuntime.PyLong_FromUnsignedLongLong((ulong)value);
195185

196186
default:
187+
if(valueisIEnumerable)
188+
{
189+
varresultlist=newPyList();
190+
foreach(objectoin(IEnumerable)value)
191+
{
192+
resultlist.Append(newPyObject(ToPython(o,o.GetType())));
193+
}
194+
returnresultlist.Handle;
195+
}
197196
result=CLRObject.GetInstHandle(value,type);
198197
returnresult;
199198
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp