| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -155,7 +155,7 @@ internal static IntPtr ToPython(object value, Type type) | |||
| 155 | 155 | // type is. we'd rather have the object bound to the actual | |
| 156 | 156 | // implementing class. | |
| 157 | 157 | ||
| 158 | - type = value.GetType(); | ||
| 158 | + type = type ?? value.GetType(); | ||
| 159 | 159 | ||
| 160 | 160 | TypeCode tc = Type.GetTypeCode(type); | |
| 161 | 161 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,7 @@ | |||
| 1 | + using System.Linq; | ||
| 1 | 2 | using System; | |
| 2 | 3 | using System.Collections; | |
| 4 | + using System.Collections.Generic; | ||
| 3 | 5 | ||
| 4 | 6 | namespace Python.Runtime | |
| 5 | 7 | { | |
@@ -10,10 +12,17 @@ namespace Python.Runtime | |||
| 10 | 12 | internal class Iterator : ExtensionType | |
| 11 | 13 | { | |
| 12 | 14 | private IEnumerator iter; | |
| 15 | + private Type type; | ||
| 13 | 16 | ||
| 14 | 17 | public Iterator(IEnumerator e) | |
| 15 | 18 | { | |
| 16 | 19 | 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(); | ||
| 17 | 26 | } | |
| 18 | 27 | ||
| 19 | 28 | ||
@@ -41,7 +50,7 @@ public static IntPtr tp_iternext(IntPtr ob) | |||
| 41 | 50 | return IntPtr.Zero; | |
| 42 | 51 | } | |
| 43 | 52 | object item = self.iter.Current; | |
| 44 | - return Converter.ToPythonImplicit(item); | ||
| 53 | + return Converter.ToPython(item, type); | ||
| 45 | 54 | } | |
| 46 | 55 | ||
| 47 | 56 | public static IntPtr tp_iter(IntPtr ob) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments