Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixes
  • Loading branch information
koubaa committed Feb 16, 2021
commit 059ab08d7bbd2effe1f1ed050d97793efc57aa78
21 changes: 7 additions & 14 deletions src/runtime/CollectionWrappers/IterableWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,21 @@ public IEnumerator<T> GetEnumerator()
{
PyObject iterObject = null;
Comment thread
koubaa marked this conversation as resolved.
using (Py.GIL())
{
iterObject = new PyObject(Runtime.PyObject_GetIter(pyObject.Handle));
}

while (true)
{
IntPtr item = IntPtr.Zero;
using (Py.GIL())
{
item = Runtime.PyIter_Next(iterObject.Handle);
}
if (item == IntPtr.Zero) break;
var item = Runtime.PyIter_Next(iterObject.Handle);
if (item == IntPtr.Zero)
{
iterObject.Dispose();
Comment thread
koubaa marked this conversation as resolved.
break;
}

object obj = null;
if (!Converter.ToManaged(item, typeof(T), out obj, true))
{
Runtime.XDecref(item);
Runtime.CheckExceptionOccurred();
yield return (T)new PyObject(item).AsManagedObject(typeof(T));
}

Runtime.XDecref(item);
yield return (T)obj;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/converterextensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ bool TryDecode(IntPtr pyHandle, out object result)

#endregion

public static void Reset()
internal static void Reset()
{
lock (encoders)
lock (decoders)
Expand Down