@@ -233,7 +233,7 @@ public static int mp_ass_subscript(IntPtr ob, IntPtr idx, IntPtr v) {
233
233
free = true ;
234
234
}
235
235
236
- // Add args given from caller
236
+ // Add args given from caller + 1 for the value
237
237
int i = Runtime . PyTuple_Size ( args ) ;
238
238
IntPtr real = Runtime . PyTuple_New ( i + 1 ) ;
239
239
for ( int n = 0 ; n < i ; n ++ ) {
@@ -243,24 +243,24 @@ public static int mp_ass_subscript(IntPtr ob, IntPtr idx, IntPtr v) {
243
243
}
244
244
245
245
// Do we need default arguments added to the list
246
- if ( cls . indexer . NeedsDefaultArgs ( ob , real ) ) {
247
- IntPtr defaultArgs = cls . indexer . GetDefaultArgs ( ob , real ) ;
248
- int sizeOfDefaultArgs = Runtime . PyTuple_Size ( defaultArgs ) ;
249
- int temp = i + sizeOfDefaultArgs ;
246
+ if ( cls . indexer . NeedsDefaultArgs ( real ) ) {
247
+ // Need to add default args to the end of real tuple
248
+ // before adding the value v
249
+ IntPtr defaultArgs = cls . indexer . GetDefaultArgs ( real ) ;
250
+ int numOfDefaultArgs = Runtime . PyTuple_Size ( defaultArgs ) ;
251
+ int temp = i + numOfDefaultArgs ;
250
252
real = Runtime . PyTuple_New ( temp + 1 ) ;
251
253
for ( int n = 0 ; n < i ; n ++ ) {
252
254
IntPtr item = Runtime . PyTuple_GetItem ( args , n ) ;
253
255
Runtime . Incref ( item ) ;
254
256
Runtime . PyTuple_SetItem ( real , n , item ) ;
255
257
}
256
258
257
- for ( int n = 0 ; n < sizeOfDefaultArgs ; n ++ ) {
258
-
259
+ for ( int n = 0 ; n < numOfDefaultArgs ; n ++ ) {
259
260
IntPtr item = Runtime . PyTuple_GetItem ( defaultArgs , n ) ;
260
261
Runtime . Incref ( item ) ;
261
262
Runtime . PyTuple_SetItem ( real , n + i , item ) ;
262
263
}
263
-
264
264
i = temp ;
265
265
}
266
266
0 commit comments