File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed
Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -155,7 +155,7 @@ internal static IntPtr ToPython(object value, Type type)
155155 // type is. we'd rather have the object bound to the actual
156156 // implementing class.
157157
158- type = value . GetType ( ) ;
158+ type = type ?? value . GetType ( ) ;
159159
160160 TypeCode tc = Type . GetTypeCode ( type ) ;
161161
Original file line number Diff line number Diff line change 1+ using System . Linq ;
12using System ;
23using System . Collections ;
4+ using System . Collections . Generic ;
35
46namespace Python . Runtime
57{
@@ -10,10 +12,17 @@ namespace Python.Runtime
1012 internal class Iterator : ExtensionType
1113 {
1214 private IEnumerator iter ;
15+ private Type type ;
1316
1417 public Iterator ( IEnumerator e )
1518 {
1619 iter = e ;
20+
21+ var genericType = e . GetType ( ) . GetInterfaces ( ) . FirstOrDefault (
22+ x => x . IsGenericType && x . GetGenericTypeDefinition ( ) == typeof ( Generic . IEnumerator < > )
23+ ) ;
24+
25+ type = genericType ? . GetGenericArguments ( ) . FirstOrDefault ( ) ;
1726 }
1827
1928
@@ -41,7 +50,7 @@ public static IntPtr tp_iternext(IntPtr ob)
4150 return IntPtr . Zero ;
4251 }
4352 object item = self . iter . Current ;
44- return Converter . ToPythonImplicit ( item ) ;
53+ return Converter . ToPython ( item , type ) ;
4554 }
4655
4756 public static IntPtr tp_iter ( IntPtr ob )
You can’t perform that action at this time.
0 commit comments