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()
30
30
var item = Runtime . PyIter_Next ( iterObject . Handle ) ;
31
31
if ( item == IntPtr . Zero )
32
32
{
33
+ Runtime . CheckExceptionOccurred ( ) ;
33
34
iterObject . Dispose ( ) ;
34
35
break ;
35
36
}
Original file line number Diff line number Diff line change @@ -56,6 +56,12 @@ public bool Contains(T item)
56
56
57
57
public void CopyTo ( T [ ] array , int arrayIndex )
58
58
{
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
+
59
65
var index = 0 ;
60
66
foreach ( var item in this )
61
67
{
@@ -69,9 +75,15 @@ protected bool removeAt(int index)
69
75
if ( IsReadOnly )
70
76
throw new NotImplementedException ( ) ;
71
77
if ( index >= Count || index < 0 )
72
- throw new IndexOutOfRangeException ( ) ;
78
+ return false ;
79
+
80
+ var result = Runtime . PySequence_DelItem ( pyObject . Handle , index ) ;
73
81
74
- return Runtime . PySequence_DelItem ( pyObject . Handle , index ) != 0 ;
82
+ if ( result == 0 )
83
+ return true ;
84
+
85
+ Runtime . CheckExceptionOccurred ( ) ;
86
+ return false ;
75
87
}
76
88
77
89
protected int indexOf ( T item )
You can’t perform that action at this time.
0 commit comments