File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed
src/runtime/CollectionWrappers Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments