@@ -858,10 +858,7 @@ class Foo "FooObject *" "&Foo_Type"
858858 def test_slot_with_parameters_and_return_type (self ):
859859 # Slots which take arguments or return something else than an
860860 # object are not supported yet; check the machinery with them.
861- slots = {
862- '__contains__' : SlotSpec (return_converter = 'int' ),
863- '__bool__' : SlotSpec (return_converter = 'int' ),
864- }
861+ slots = {'__bool__' : SlotSpec (return_converter = 'int' )}
865862 block = """
866863 /*[clinic input]
867864 output everything block
@@ -3356,6 +3353,20 @@ class Foo "FooObject *" ""
33563353 self .assertEqual (function .return_converter .type , "PyObject *" )
33573354 self .assertEqual (list (function .parameters ), ["self" ])
33583355
3356+ def test_slot_coexist_is_a_method (self ):
3357+ # dict.__contains__ is a METH_COEXIST method, not the slot.
3358+ function = self .parse_function ("""
3359+ module foo
3360+ class Foo "FooObject *" ""
3361+ @coexist
3362+ Foo.__contains__
3363+ key: object
3364+ /
3365+ """ , signatures_in_block = 3 , function_index = 2 )
3366+ self .assertIs (function .kind , FunctionKind .CALLABLE )
3367+ self .assertIsNone (function .slot )
3368+ self .assertIn ("METH_COEXIST" , function .methoddef_flags )
3369+
33593370 def test_slot_parameters (self ):
33603371 # __getitem__ is not supported yet; its parameter gives the slot
33613372 # (Py_ssize_t for sq_item, object for mp_subscript) and is not parsed.
@@ -3396,8 +3407,6 @@ def test_slot_errors(self):
33963407 "'__next__' must be a normal method" ),
33973408 ("@getter\n Foo.__next__" ,
33983409 "'__next__' must be a normal method" ),
3399- ("@coexist\n Foo.__next__" ,
3400- "@coexist cannot be applied to '__next__'" ),
34013410 ("@vectorcall\n Foo.__next__" ,
34023411 "@vectorcall can only be used with __init__ and __new__" ),
34033412 ("Foo.__next__ -> int" ,
0 commit comments