Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 059ab08

Browse files
committed
fixes
1 parent 080dbc3 commit 059ab08

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

src/runtime/CollectionWrappers/IterableWrapper.cs

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,21 @@ public IEnumerator<T> GetEnumerator()
2121
{
2222
PyObject iterObject = null;
2323
using (Py.GIL())
24-
{
2524
iterObject = new PyObject(Runtime.PyObject_GetIter(pyObject.Handle));
26-
}
2725

2826
while (true)
2927
{
30-
IntPtr item = IntPtr.Zero;
3128
using (Py.GIL())
3229
{
33-
item = Runtime.PyIter_Next(iterObject.Handle);
34-
}
35-
if (item == IntPtr.Zero) break;
30+
var item = Runtime.PyIter_Next(iterObject.Handle);
31+
if (item == IntPtr.Zero)
32+
{
33+
iterObject.Dispose();
34+
break;
35+
}
3636

37-
object obj = null;
38-
if (!Converter.ToManaged(item, typeof(T), out obj, true))
39-
{
40-
Runtime.XDecref(item);
41-
Runtime.CheckExceptionOccurred();
37+
yield return (T)new PyObject(item).AsManagedObject(typeof(T));
4238
}
43-
44-
Runtime.XDecref(item);
45-
yield return (T)obj;
4639
}
4740
}
4841
}

src/runtime/converterextensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ bool TryDecode(IntPtr pyHandle, out object result)
154154

155155
#endregion
156156

157-
public static void Reset()
157+
internal static void Reset()
158158
{
159159
lock (encoders)
160160
lock (decoders)

0 commit comments

Comments
 (0)