10000 Catch exceptions from iterator.MoveNext() · sdpython/pythonnet@6b03c63 · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Jul 22, 2023. It is now read-only.

Commit 6b03c63

Browse files
rickardraysearchabessen
authored andcommitted
Catch exceptions fr 10000 om iterator.MoveNext()
(cherry picked from commit 8531755)
1 parent d0f34e9 commit 6b03c63

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/runtime/iterator.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,21 @@ public Iterator(IEnumerator e)
2323
public static IntPtr tp_iternext(IntPtr ob)
2424
{
2525
var self = GetManagedObject(ob) as Iterator;
26-
if (!self.iter.MoveNext())
26+
try
2727
{
28-
Exceptions.SetError(Exceptions.StopIteration, Runtime.PyNone);
28+
if (!self.iter.MoveNext())
29+
{
30+
Exceptions.SetError(Exceptions.StopIteration, Runtime.PyNone);
31+
return IntPtr.Zero;
32+
}
33+
}
34+
catch (Exception e)
35+
{
36+
if (e.InnerException != null)
37+
{
38+
e = e.InnerException;
39+
}
40+
Exceptions.SetError(e);
2941
return IntPtr.Zero;
3042
}
3143
object item = self.iter.Current;

0 commit comments

Comments
 (0)
0