10000 respond to comments · pythonnet/pythonnet@3043201 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3043201

Browse files
committed
respond to comments
1 parent 432c09e commit 3043201

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/runtime/CollectionWrappers/IterableWrapper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ public IEnumerator<T> GetEnumerator()
3030
var item = Runtime.PyIter_Next(iterObject.Handle);
3131
if (item == IntPtr.Zero)
3232
{
33+
Runtime.CheckExceptionOccurred();
3334
iterObject.Dispose();
3435
break;
3536
}

src/runtime/CollectionWrappers/SequenceWrapper.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ public bool Contains(T item)
5656

5757
public void CopyTo(T[] array, int arrayIndex)
5858
{
59+
if (array == null)
60+
throw new NullReferenceException();
61+
62+
if ((array.Length - arrayIndex) < this.Count)
63+
throw new InvalidOperationException("Attempting to copy to an array that is too small");
64+
5965
var index = 0;
6066
foreach (var item in this)
6167
{
@@ -69,9 +75,15 @@ protected bool removeAt(int index)
6975
if (IsReadOnly)
7076
throw new NotImplementedException();
7177
if (index >= Count || index < 0)
72-
throw new IndexOutOfRangeException();
78+
return false;
79+
80+
var result = Runtime.PySequence_DelItem(pyObject.Handle, index);
7381

74-
return Runtime.PySequence_DelItem(pyObject.Handle, index) != 0;
82+
if (result == 0)
83+
return true;
84+
85+
Runtime.CheckExceptionOccurred();
86+
return false;
7587
}
7688

7789
protected int indexOf(T item)

0 commit comments

Comments
 (0)
0