@@ -280,6 +280,15 @@ class DummyDequeLen(set):
280
280
def __len__ (self ):
281
281
return 42
282
282
283
+
284
+ class DictSubclassWithSequenceMethods (dict ):
285
+ def __getitem__ (self , key ):
286
+ return key
287
+
288
+ def __setitem__ (self , key , value ):
289
+ pass
290
+
291
+
283
292
def _default_bin_arith_args ():
284
293
return (
285
294
(0 , 0 ),
@@ -374,7 +383,8 @@ def _size_and_check_args():
374
383
(DummyDeque (),),
375
384
(DummyDeque ([1 ,2 ,3 ]),),
376
385
(DummyDequeLen (),),
377
- (DummyDequeLen ([1 ,2 ,3 ]),),
386
+ (DummyDequeLen ([1 ,2 ,3 ]),),
387
+ (DictSubclassWithSequenceMethods (),),
378
388
)
379
389
380
390
class TestAbstractWithNative (object ):
@@ -1164,6 +1174,7 @@ class TestAbstract(CPyExtTestCase):
1164
1174
({'a' , 'b' }, 0 ),
1165
1175
(DummyListSubclass (), 1 ),
1166
1176
('hello' , 1 ),
1177
+ (DictSubclassWithSequenceMethods (), 1 ),
1167
1178
),
1168
1179
resultspec = "O" ,
1169
1180
argspec = 'On' ,
@@ -1336,6 +1347,7 @@ def _reference_delslice(args):
1336
1347
([], 10 , 1 ),
1337
1348
(['a' , 'b' , 'c' ], 2 , 'z' ),
1338
1349
('hello' , 2 , 'z' ),
1350
+ (DictSubclassWithSequenceMethods (), 1 , 1 )
1339
1351
),
1340
1352
code = ''' PyObject* wrap_PySequence_SetItem(PyObject* sequence, Py_ssize_t idx, PyObject* value) {
1341
1353
if (PySequence_SetItem(sequence, idx, value) < 0) {
0 commit comments