8000 fixes · pythonnet/pythonnet@1fdc717 · GitHub
[go: up one dir, main page]

Skip to content

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

< 8000 div class="position-relative HeaderMenu-link-wrap d-lg-inline-block">
Appearance settings

Commit 1fdc717

Browse files
committed
fixes
1 parent 61bd107 commit 1fdc717

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
@@ -157,7 +157,7 @@ bool TryDecode(IntPtr pyHandle, out object result)
157157

158158
#endregion
159159

160-
public static void Reset()
160+
internal static void Reset()
161161
{
162162
lock (encoders)
163163
lock (decoders)

0 commit comments

Comments
 (0)
0