@@ -1446,39 +1446,54 @@ _testclinic_TestClass_defclass_posonly_varpos_impl(PyObject *self,
14461446/*[clinic input]
14471447@disable fastcall
14481448@classmethod
1449- _testclinic.TestClass.__new__ as varpos_no_fastcall
1449+ _testclinic.TestClass.varpos_no_fastcall
14501450
14511451 *args: tuple
14521452
14531453# Do NOT use __new__ to generate this method. Compare:
14541454#
1455- # With __new__
1455+ # [1] With __new__ (METH_KEYWORDS must be added even if we don't want to)
14561456#
1457- # varpos_no_fastcall_1(PyTypeObject *type, PyObject *args, PyObject *kwargs)
1458- # varpos_no_fastcall_impl_1(PyTypeObject *type, PyObject *args)
1457+ # varpos_no_fastcall(PyTypeObject *type, PyObject *args, PyObject *kwargs)
1458+ # varpos_no_fastcall_impl(PyTypeObject *type, PyObject *args)
1459+ # no auto-generated METHODDEF macro
14591460#
1460- # Without __new__ and an explicit "@disable fastcall"
1461+ # [2] Without __new__ (automatically METH_FASTCALL, not good for this test)
14611462#
1462- # varpos_no_fastcall_2(PyObject *type, PyObject *args)
1463- # varpos_no_fastcall_impl_2(PyTypeObject *type, PyObject *args)
1463+ # varpos_no_fastcall_impl(PyObject *type, PyObject *args)
1464+ # varpos_no_fastcall(PyObject *type, PyObject *const *args, Py_ssize_t nargs)
1465+ # flags = METH_FASTCALL|METH_CLASS
14641466#
1465- # We want to test a non-fastcall class method (i.e. something like __new__)
1466- # but without triggering an undefined behaviour at runtime in cfunction_call().
1467+ # [3] Without __new__ + "@disable fastcall" (what we want)
1468+ #
1469+ # varpos_no_fastcall(PyObject *type, PyObject *args)
1470+ # varpos_no_fastcall_impl(PyTypeObject *type, PyObject *args)
1471+ # flags = METH_VARARGS|METH_CLASS
1472+ #
1473+ # We want to test a non-fastcall class method but without triggering an
1474+ # undefined behaviour at runtime in cfunction_call().
14671475#
14681476# At runtime, a METH_VARARGS method called in cfunction_call() must be:
14691477#
14701478# (PyObject *, PyObject *) -> PyObject *
14711479# (PyObject *, PyObject *, PyObject *) -> PyObject *
14721480#
1473- # depending on whether METH_KEYWORDS is present or not. Changin AC to make
1474- # varpos_no_fastcall_1() compatible with cfunction_call() would also affect
1475- # how the regular __new__ methods are generated (they ALWAYS support 'kwargs').
1476- # Thus, for testing non-fastcall class methods, "@disable fastcall" is needed.
1481+ # depending on whether METH_KEYWORDS is present or not.
1482+ #
1483+ # AC determines whether a method is a __new__-like method solely bsaed
1484+ # on the method name, and not on its usage or its c_basename, and those
1485+ # methods must always be used with METH_VARARGS|METH_KEYWORDS|METH_CLASS.
1486+ #
1487+ # In particular, using [1] forces us to add METH_KEYWORDS even though
1488+ # the test shouldn't be expecting keyword arguments. Using [2] is also
1489+ # not possible since we want to test non-fastcalls. This is the reason
1490+ # why we need to be able to disable the METH_FASTCALL flag.
14771491[clinic start generated code]*/
14781492
14791493static PyObject *
1480- varpos_no_fastcall_impl (PyTypeObject * type , PyObject * args )
1481- /*[clinic end generated code: output=04e94f2898bb2dde input=df0b72d3e7784a18]*/
1494+ _testclinic_TestClass_varpos_no_fastcall_impl (PyTypeObject * type ,
1495+ PyObject * args )
1496+ /*[clinic end generated code: output=edfacec733aeb9c5 input=e385fc8a3af7ae44]*/
14821497{
14831498 return Py_NewRef (args );
14841499}
@@ -1487,7 +1502,7 @@ varpos_no_fastcall_impl(PyTypeObject *type, PyObject *args)
14871502/*[clinic input]
14881503@disable fastcall
14891504@classmethod
1490- _testclinic.TestClass.cm as posonly_varpos_no_fastcall
1505+ _testclinic.TestClass.posonly_varpos_no_fastcall
14911506
14921507 a: object
14931508 b: object
@@ -1497,9 +1512,11 @@ _testclinic.TestClass.cm as posonly_varpos_no_fastcall
14971512[clinic start generated code]*/
14981513
14991514static PyObject *
1500- posonly_varpos_no_fastcall_impl (PyTypeObject * type , PyObject * a , PyObject * b ,
1501- PyObject * args )
1502- /*[clinic end generated code: output=b0a0425719f69f5a input=c8870f84456e68be]*/
1515+ _testclinic_TestClass_posonly_varpos_no_fastcall_impl (PyTypeObject * type ,
1516+ PyObject * a ,
1517+ PyObject * b ,
1518+ PyObject * args )
1519+ /*[clinic end generated code: output=2c5184aebe020085 input=3621dd172c5193d8]*/
15031520{
15041521 return pack_arguments_newref (3 , a , b , args );
15051522}
@@ -1508,7 +1525,7 @@ posonly_varpos_no_fastcall_impl(PyTypeObject *type, PyObject *a, PyObject *b,
15081525/*[clinic input]
15091526@disable fastcall
15101527@classmethod
1511- _testclinic.TestClass.cm as posonly_req_opt_varpos_no_fastcall
1528+ _testclinic.TestClass.posonly_req_opt_varpos_no_fastcall
15121529
15131530 a: object
15141531 b: object = False
@@ -1518,9 +1535,11 @@ _testclinic.TestClass.cm as posonly_req_opt_varpos_no_fastcall
15181535[clinic start generated code]*/
15191536
15201537static PyObject *
1521- posonly_req_opt_varpos_no_fastcall_impl (PyTypeObject * type , PyObject * a ,
1522- PyObject * b , PyObject * args )
1523- /*[clinic end generated code: output=3c44915b1a554e2d input=9e29ef335e399e8e]*/
1538+ _testclinic_TestClass_posonly_req_opt_varpos_no_fastcall_impl (PyTypeObject * type ,
1539+ PyObject * a ,
1540+ PyObject * b ,
1541+ PyObject * args )
1542+ /*[clinic end generated code: output=08e533d59bceadf6 input=922fa7851b32e2dd]*/
15241543{
15251544 return pack_arguments_newref (3 , a , b , args );
15261545}
@@ -1529,7 +1548,7 @@ posonly_req_opt_varpos_no_fastcall_impl(PyTypeObject *type, PyObject *a,
15291548/*[clinic input]
15301549@disable fastcall
15311550@classmethod
1532- _testclinic.TestClass.cm as posonly_poskw_varpos_no_fastcall
1551+ _testclinic.TestClass.posonly_poskw_varpos_no_fastcall
15331552
15341553 a: object
15351554 /
@@ -1539,9 +1558,11 @@ _testclinic.TestClass.cm as posonly_poskw_varpos_no_fastcall
15391558[clinic start generated code]*/
15401559
15411560static PyObject *
1542- posonly_poskw_varpos_no_fastcall_impl (PyTypeObject * type , PyObject * a ,
1543- PyObject * b , PyObject * args )
1544- /*[clinic end generated code: output=6ad74bed4bdc7f96 input=66226ea6c3d38c36]*/
1561+ _testclinic_TestClass_posonly_poskw_varpos_no_fastcall_impl (PyTypeObject * type ,
1562+ PyObject * a ,
1563+ PyObject * b ,
1564+ PyObject * args )
1565+ /*[clinic end generated code: output=8ecfda20850e689f input=60443fe0bb8fe3e0]*/
15451566{
15461567 return pack_arguments_newref (3 , a , b , args );
15471568}
@@ -1550,16 +1571,17 @@ posonly_poskw_varpos_no_fastcall_impl(PyTypeObject *type, PyObject *a,
15501571/*[clinic input]
15511572@disable fastcall
15521573@classmethod
1553- _testclinic.TestClass.cm as varpos_array_no_fastcall
1574+ _testclinic.TestClass.varpos_array_no_fastcall
15541575
15551576 *args: array
15561577
15571578[clinic start generated code]*/
15581579
15591580static PyObject *
1560- varpos_array_no_fastcall_impl (PyTypeObject * type , PyObject * const * args ,
1561- Py_ssize_t args_length )
1562- /*[clinic end generated code: output=f99d984346c60d42 input=52b2e8011dbee112]*/
1581+ _testclinic_TestClass_varpos_array_no_fastcall_impl (PyTypeObject * type ,
1582+ PyObject * const * args ,
1583+ Py_ssize_t args_length )
1584+ /*[clinic end generated code: output=27c9da663e942617 input=9ba5ae1f1eb58777]*/
15631585{
15641586 return _PyTuple_FromArray (args , args_length );
15651587}
@@ -1568,7 +1590,7 @@ varpos_array_no_fastcall_impl(PyTypeObject *type, PyObject * const *args,
15681590/*[clinic input]
15691591@disable fastcall
15701592@classmethod
1571- _testclinic.TestClass.cm as posonly_varpos_array_no_fastcall
1593+ _testclinic.TestClass.posonly_varpos_array_no_fastcall
15721594
15731595 a: object
15741596 b: object
@@ -1578,10 +1600,12 @@ _testclinic.TestClass.cm as posonly_varpos_array_no_fastcall
15781600[clinic start generated code]*/
15791601
15801602static PyObject *
1581- posonly_varpos_array_no_fastcall_impl (PyTypeObject * type , PyObject * a ,
1582- PyObject * b , PyObject * const * args ,
1583- Py_ssize_t args_length )
1584- /*[clinic end generated code: output=1eec4da1fb5b5978 input=78fd1e9358b8987f]*/
1603+ _testclinic_TestClass_posonly_varpos_array_no_fastcall_impl (PyTypeObject * type ,
1604+ PyObject * a ,
1605+ PyObject * b ,
1606+ PyObject * const * args ,
1607+ Py_ssize_t args_length )
1608+ /*[clinic end generated code: output=71e676f1870b5a7e input=18eadf4c6eaab613]*/
15851609{
15861610 return pack_arguments_2pos_varpos (a , b , args , args_length );
15871611}
@@ -1590,7 +1614,7 @@ posonly_varpos_array_no_fastcall_impl(PyTypeObject *type, PyObject *a,
15901614/*[clinic input]
15911615@disable fastcall
15921616@classmethod
1593- _testclinic.TestClass.cm as posonly_req_opt_varpos_array_no_fastcall
1617+ _testclinic.TestClass.posonly_req_opt_varpos_array_no_fastcall
15941618
15951619 a: object
15961620 b: object = False
@@ -1600,11 +1624,12 @@ _testclinic.TestClass.cm as posonly_req_opt_varpos_array_no_fastcall
16001624[clinic start generated code]*/
16011625
16021626static PyObject *
1603- posonly_req_opt_varpos_array_no_fastcall_impl (PyTypeObject * type ,
1604- PyObject * a , PyObject * b ,
1605- PyObject * const * args ,
1606- Py_ssize_t args_length )
1607- /*[clinic end generated code: output=88041c2176135218 input=f730318da80b94c1]*/
1627+ _testclinic_TestClass_posonly_req_opt_varpos_array_no_fastcall_impl (PyTypeObject * type ,
1628+ PyObject * a ,
1629+ PyObject * b ,
1630+ PyObject * const * args ,
1631+ Py_ssize_t args_length )
1632+ /*[clinic end generated code: output=abb395cae91d48ac input=5bf791fdad70b480]*/
16081633{
16091634 return pack_arguments_2pos_varpos (a , b , args , args_length );
16101635}
@@ -1613,7 +1638,7 @@ posonly_req_opt_varpos_array_no_fastcall_impl(PyTypeObject *type,
16131638/*[clinic input]
16141639@disable fastcall
16151640@classmethod
1616- _testclinic.TestClass.cm as posonly_poskw_varpos_array_no_fastcall
1641+ _testclinic.TestClass.posonly_poskw_varpos_array_no_fastcall
16171642
16181643 a: object
16191644 /
@@ -1623,11 +1648,12 @@ _testclinic.TestClass.cm as posonly_poskw_varpos_array_no_fastcall
16231648[clinic start generated code]*/
16241649
16251650static PyObject *
1626- posonly_poskw_varpos_array_no_fastcall_impl (PyTypeObject * type , PyObject * a ,
1627- PyObject * b ,
1628- PyObject * const * args ,
1629- Py_ssize_t args_length )
1630- /*[clinic end generated code: output=70eda18c3667681e input=a98374a618ec8d36]*/
1651+ _testclinic_TestClass_posonly_poskw_varpos_array_no_fastcall_impl (PyTypeObject * type ,
1652+ PyObject * a ,
1653+ PyObject * b ,
1654+ PyObject * const * args ,
1655+ Py_ssize_t args_length )
1656+ /*[clinic end generated code: output=aaddd9530048b229 input=9ed3842f4d472d45]*/
16311657{
16321658 return pack_arguments_2pos_varpos (a , b , args , args_length );
16331659}
@@ -1638,28 +1664,15 @@ static struct PyMethodDef test_class_methods[] = {
16381664 _TESTCLINIC_TESTCLASS_DEFCLASS_VARPOS_METHODDEF
16391665 _TESTCLINIC_TESTCLASS_DEFCLASS_POSONLY_VARPOS_METHODDEF
16401666
1641- {"varpos_no_fastcall" , varpos_no_fastcall ,
1642- METH_VARARGS |METH_CLASS , "" },
1643- {"posonly_varpos_no_fastcall" , posonly_varpos_no_fastcall ,
1644- METH_VARARGS |METH_CLASS , "" },
1645- {"posonly_req_opt_varpos_no_fastcall" , posonly_req_opt_varpos_no_fastcall ,
1646- METH_VARARGS |METH_CLASS , "" },
1647- {"posonly_poskw_varpos_no_fastcall" ,
1648- _PyCFunction_CAST (posonly_poskw_varpos_no_fastcall ),
1649- METH_VARARGS |METH_KEYWORDS |METH_CLASS , "" },
1650-
1651- {"varpos_array_no_fastcall" ,
1652- varpos_array_no_fastcall ,
1653- METH_VARARGS |METH_CLASS , "" },
1654- {"posonly_varpos_array_no_fastcall" ,
1655- posonly_varpos_array_no_fastcall ,
1656- METH_VARARGS |METH_CLASS , "" },
1657- {"posonly_req_opt_varpos_array_no_fastcall" ,
1658- posonly_req_opt_varpos_array_no_fastcall ,
1659- METH_VARARGS |METH_CLASS , "" },
1660- {"posonly_poskw_varpos_array_no_fastcall" ,
1661- _PyCFunction_CAST (posonly_poskw_varpos_array_no_fastcall ),
1662- METH_VARARGS |METH_KEYWORDS |METH_CLASS , "" },
1667+ _TESTCLINIC_TESTCLASS_VARPOS_NO_FASTCALL_METHODDEF
1668+ _TESTCLINIC_TESTCLASS_POSONLY_VARPOS_NO_FASTCALL_METHODDEF
1669+ _TESTCLINIC_TESTCLASS_POSONLY_REQ_OPT_VARPOS_NO_FASTCALL_METHODDEF
1670+ _TESTCLINIC_TESTCLASS_POSONLY_POSKW_VARPOS_NO_FASTCALL_METHODDEF
1671+
1672+ _TESTCLINIC_TESTCLASS_VARPOS_ARRAY_NO_FASTCALL_METHODDEF
1673+ _TESTCLINIC_TESTCLASS_POSONLY_VARPOS_ARRAY_NO_FASTCALL_METHODDEF
1674+ _TESTCLINIC_TESTCLASS_POSONLY_REQ_OPT_VARPOS_ARRAY_NO_FASTCALL_METHODDEF
1675+ _TESTCLINIC_TESTCLASS_POSONLY_POSKW_VARPOS_ARRAY_NO_FASTCALL_METHODDEF
16631676
16641677 {NULL , NULL }
16651678};
0 commit comments