@@ -1443,25 +1443,69 @@ _testclinic_TestClass_defclass_posonly_varpos_impl(PyObject *self,
1443
1443
}
1444
1444
1445
1445
1446
- /*[clinic input]
1446
+ /*
1447
+ * # Do NOT use __new__ to generate this method. Compare:
1448
+ *
1449
+ * [1] With __new__ (METH_KEYWORDS must be added even if we don't want to)
1450
+ *
1451
+ * varpos_no_fastcall(PyTypeObject *type, PyObject *args, PyObject *kwargs)
1452
+ * varpos_no_fastcall_impl(PyTypeObject *type, PyObject *args)
1453
+ * no auto-generated METHODDEF macro
1454
+ *
1455
+ * [2] Without __new__ (automatically METH_FASTCALL, not good for this test)
1456
+ *
1457
+ * varpos_no_fastcall_impl(PyObject *type, PyObject *args)
1458
+ * varpos_no_fastcall(PyObject *type, PyObject *const *args, Py_ssize_t nargs)
1459
+ * flags = METH_FASTCALL|METH_CLASS
1460
+ *
1461
+ * [3] Without __new__ + "@disable fastcall" (what we want)
1462
+ *
1463
+ * varpos_no_fastcall(PyObject *type, PyObject *args)
1464
+ * varpos_no_fastcall_impl(PyTypeObject *type, PyObject *args)
1465
+ * flags = METH_VARARGS|METH_CLASS
1466
+ *
1467
+ * We want to test a non-fastcall class method but without triggering an
1468
+ * undefined behaviour at runtime in cfunction_call().
1469
+ *
1470
+ * At runtime, a METH_VARARGS method called in cfunction_call() must be:
1471
+ *
1472
+ * (PyObject *, PyObject *) -> PyObject *
1473
+ * (PyObject *, PyObject *, PyObject *) -> PyObject *
1474
+ *
1475
+ * depending on whether METH_KEYWORDS is present or not.
1476
+ *
1477
+ * AC determines whether a method is a __new__-like method solely bsaed
1478
+ * on the method name, and not on its usage or its c_basename, and those
1479
+ * methods must always be used with METH_VARARGS|METH_KEYWORDS|METH_CLASS.
1480
+ *
1481
+ * In particular, using [1] forces us to add METH_KEYWORDS even though
1482
+ * the test shouldn't be expecting keyword arguments. Using [2] is also
1483
+ * not possible since we want to test non-fastcalls. This is the reason
1484
+ * why we need to be able to disable the METH_FASTCALL flag.
1485
+ */
1486
+
1487
+ /*[clinic input]
1488
+ @disable fastcall
1447
1489
@classmethod
1448
- _testclinic.TestClass.__new__ as varpos_no_fastcall
1490
+ _testclinic.TestClass.varpos_no_fastcall
1449
1491
1450
1492
*args: tuple
1451
1493
1452
1494
[clinic start generated code]*/
1453
1495
1454
1496
static PyObject *
1455
- varpos_no_fastcall_impl (PyTypeObject * type , PyObject * args )
1456
- /*[clinic end generated code: output=04e94f2898bb2dde input=c5d3d30a6589f97f]*/
1497
+ _testclinic_TestClass_varpos_no_fastcall_impl (PyTypeObject * type ,
1498
+ PyObject * args )
1499
+ /*[clinic end generated code: output=edfacec733aeb9c5 input=3f298d143aa98048]*/
1457
1500
{
1458
1501
return Py_NewRef (args );
1459
1502
}
1460
1503
1461
1504
1462
1505
/*[clinic input]
1506
+ @disable fastcall
1463
1507
@classmethod
1464
- _testclinic.TestClass.__new__ as posonly_varpos_no_fastcall
1508
+ _testclinic.TestClass.posonly_varpos_no_fastcall
1465
1509
1466
1510
a: object
1467
1511
b: object
@@ -1471,17 +1515,20 @@ _testclinic.TestClass.__new__ as posonly_varpos_no_fastcall
1471
1515
[clinic start generated code]*/
1472
1516
1473
1517
static PyObject *
1474
- posonly_varpos_no_fastcall_impl (PyTypeObject * type , PyObject * a , PyObject * b ,
1475
- PyObject * args )
1476
- /*[clinic end generated code: output=b0a0425719f69f5a input=10f29f2c2c6bfdc4]*/
1518
+ _testclinic_TestClass_posonly_varpos_no_fastcall_impl (PyTypeObject * type ,
1519
+ PyObject * a ,
1520
+ PyObject * b ,
1521
+ PyObject * args )
1522
+ /*[clinic end generated code: output=2c5184aebe020085 input=3621dd172c5193d8]*/
1477
1523
{
1478
1524
return pack_arguments_newref (3 , a , b , args );
1479
1525
}
1480
1526
1481
1527
1482
1528
/*[clinic input]
1529
+ @disable fastcall
1483
1530
@classmethod
1484
- _testclinic.TestClass.__new__ as posonly_req_opt_varpos_no_fastcall
1531
+ _testclinic.TestClass.posonly_req_opt_varpos_no_fastcall
1485
1532
1486
1533
a: object
1487
1534
b: object = False
@@ -1491,17 +1538,20 @@ _testclinic.TestClass.__new__ as posonly_req_opt_varpos_no_fastcall
1491
1538
[clinic start generated code]*/
1492
1539
1493
1540
static PyObject *
1494
- posonly_req_opt_varpos_no_fastcall_impl (PyTypeObject * type , PyObject * a ,
1495
- PyObject * b , PyObject * args )
1496
- /*[clinic end generated code: output=3c44915b1a554e2d input=d319302a8748147c]*/
1541
+ _testclinic_TestClass_posonly_req_opt_varpos_no_fastcall_impl (PyTypeObject * type ,
1542
+ PyObject * a ,
1543
+ PyObject * b ,
1544
+ PyObject * args )
1545
+ /*[clinic end generated code: output=08e533d59bceadf6 input=922fa7851b32e2dd]*/
1497
1546
{
1498
1547
return pack_arguments_newref (3 , a , b , args );
1499
1548
}
1500
1549
1501
1550
1502
1551
/*[clinic input]
1552
+ @disable fastcall
1503
1553
@classmethod
1504
- _testclinic.TestClass.__new__ as posonly_poskw_varpos_no_fastcall
1554
+ _testclinic.TestClass.posonly_poskw_varpos_no_fastcall
1505
1555
1506
1556
a: object
1507
1557
/
@@ -1511,34 +1561,39 @@ _testclinic.TestClass.__new__ as posonly_poskw_varpos_no_fastcall
1511
1561
[clinic start generated code]*/
1512
1562
1513
1563
static PyObject *
1514
- posonly_poskw_varpos_no_fastcall_impl (PyTypeObject * type , PyObject * a ,
1515
- PyObject * b , PyObject * args )
1516
- /*[clinic end generated code: output=6ad74bed4bdc7f96 input=1f8c113e749414a3]*/
1564
+ _testclinic_TestClass_posonly_poskw_varpos_no_fastcall_impl (PyTypeObject * type ,
1565
+ PyObject * a ,
1566
+ PyObject * b ,
1567
+ PyObject * args )
1568
+ /*[clinic end generated code: output=8ecfda20850e689f input=60443fe0bb8fe3e0]*/
1517
1569
{
1518
1570
return pack_arguments_newref (3 , a , b , args );
1519
1571
}
1520
1572
1521
1573
1522
1574
/*[clinic input]
1575
+ @disable fastcall
1523
1576
@classmethod
1524
- _testclinic.TestClass.__new__ as varpos_array_no_fastcall
1577
+ _testclinic.TestClass.varpos_array_no_fastcall
1525
1578
1526
1579
*args: array
1527
1580
1528
1581
[clinic start generated code]*/
1529
1582
1530
1583
static PyObject *
1531
- varpos_array_no_fastcall_impl (PyTypeObject * type , PyObject * const * args ,
1532
- Py_ssize_t args_length )
1533
- /*[clinic end generated code: output=f99d984346c60d42 input=368d8eea6de48c12]*/
1584
+ _testclinic_TestClass_varpos_array_no_fastcall_impl (PyTypeObject * type ,
1585
+ PyObject * const * args ,
1586
+ Py_ssize_t args_length )
1587
+ /*[clinic end generated code: output=27c9da663e942617 input=9ba5ae1f1eb58777]*/
1534
1588
{
1535
1589
return _PyTuple_FromArray (args , args_length );
1536
1590
}
1537
1591
1538
1592
1539
1593
/*[clinic input]
1594
+ @disable fastcall
1540
1595
@classmethod
1541
- _testclinic.TestClass.__new__ as posonly_varpos_array_no_fastcall
1596
+ _testclinic.TestClass.posonly_varpos_array_no_fastcall
1542
1597
1543
1598
a: object
1544
1599
b: object
@@ -1548,18 +1603,21 @@ _testclinic.TestClass.__new__ as posonly_varpos_array_no_fastcall
1548
1603
[clinic start generated code]*/
1549
1604
1550
1605
static PyObject *
1551
- posonly_varpos_array_no_fastcall_impl (PyTypeObject * type , PyObject * a ,
1552
- PyObject * b , PyObject * const * args ,
1553
- Py_ssize_t args_length )
1554
- /*[clinic end generated code: output=1eec4da1fb5b5978 input=7330c8d819a23548]*/
1606
+ _testclinic_TestClass_posonly_varpos_array_no_fastcall_impl (PyTypeObject * type ,
1607
+ PyObject * a ,
1608
+ PyObject * b ,
1609
+ PyObject * const * args ,
1610
+ Py_ssize_t args_length )
1611
+ /*[clinic end generated code: output=71e676f1870b5a7e input=18eadf4c6eaab613]*/
1555
1612
{
1556
1613
return pack_arguments_2pos_varpos (a , b , args , args_length );
1557
1614
}
1558
1615
1559
1616
1560
1617
/*[clinic input]
1618
+ @disable fastcall
1561
1619
@classmethod
1562
- _testclinic.TestClass.__new__ as posonly_req_opt_varpos_array_no_fastcall
1620
+ _testclinic.TestClass.posonly_req_opt_varpos_array_no_fastcall
1563
1621
1564
1622
a: object
1565
1623
b: object = False
@@ -1569,19 +1627,21 @@ _testclinic.TestClass.__new__ as posonly_req_opt_varpos_array_no_fastcall
1569
1627
[clinic start generated code]*/
1570
1628
1571
1629
static PyObject *
1572
- posonly_req_opt_varpos_array_no_fastcall_impl (PyTypeObject * type ,
1573
- PyObject * a , PyObject * b ,
1574
- PyObject * const * args ,
1575
- Py_ssize_t args_length )
1576
- /*[clinic end generated code: output=88041c2176135218 input=7f5fd34ee5f9e0bf]*/
1630
+ _testclinic_TestClass_posonly_req_opt_varpos_array_no_fastcall_impl (PyTypeObject * type ,
1631
+ PyObject * a ,
1632
+ PyObject * b ,
1633
+ PyObject * const * args ,
1634
+ Py_ssize_t args_length )
1635
+ /*[clinic end generated code: output=abb395cae91d48ac input=5bf791fdad70b480]*/
1577
1636
{
1578
1637
return pack_arguments_2pos_varpos (a , b , args , args_length );
1579
1638
}
1580
1639
1581
1640
1582
1641
/*[clinic input]
1642
+ @disable fastcall
1583
1643
@classmethod
1584
- _testclinic.TestClass.__new__ as posonly_poskw_varpos_array_no_fastcall
1644
+ _testclinic.TestClass.posonly_poskw_varpos_array_no_fastcall
1585
1645
1586
1646
a: object
1587
1647
/
@@ -1591,11 +1651,12 @@ _testclinic.TestClass.__new__ as posonly_poskw_varpos_array_no_fastcall
1591
1651
[clinic start generated code]*/
1592
1652
1593
1653
static PyObject *
1594
- posonly_poskw_varpos_array_no_fastcall_impl (PyTypeObject * type , PyObject * a ,
1595
- PyObject * b ,
1596
- PyObject * const * args ,
1597
- Py_ssize_t args_length )
1598
- /*[clinic end generated code: output=70eda18c3667681e input=2b0fcd7bd9bb865c]*/
1654
+ _testclinic_TestClass_posonly_poskw_varpos_array_no_fastcall_impl (PyTypeObject * type ,
1655
+ PyObject * a ,
1656
+ PyObject * b ,
1657
+ PyObject * const * args ,
1658
+ Py_ssize_t args_length )
1659
+ /*[clinic end generated code: output=aaddd9530048b229 input=9ed3842f4d472d45]*/
1599
1660
{
1600
1661
return pack_arguments_2pos_varpos (a , b , args , args_length );
1601
1662
}
@@ -1606,27 +1667,15 @@ static struct PyMethodDef test_class_methods[] = {
1606
1667
_TESTCLINIC_TESTCLASS_DEFCLASS_VARPOS_METHODDEF
1607
1668
_TESTCLINIC_TESTCLASS_DEFCLASS_POSONLY_VARPOS_METHODDEF
1608
1669
1609
- {"varpos_no_fastcall" , _PyCFunction_CAST (varpos_no_fastcall ),
1610
- METH_VARARGS |METH_KEYWORDS |METH_CLASS , "" },
1611
- {"posonly_varpos_no_fastcall" , _PyCFunction_CAST (posonly_varpos_no_fastcall ),
1612
- METH_VARARGS |METH_KEYWORDS |METH_CLASS , "" },
1613
- {"posonly_req_opt_varpos_no_fastcall" , _PyCFunction_CAST (posonly_req_opt_varpos_no_fastcall ),
1614
- METH_VARARGS |METH_KEYWORDS |METH_CLASS , "" },
1615
- {"posonly_poskw_varpos_no_fastcall" , _PyCFunction_CAST (posonly_poskw_varpos_no_fastcall ),
1616
- METH_VARARGS |METH_KEYWORDS |METH_CLASS , "" },
1617
-
1618
- {"varpos_array_no_fastcall" ,
1619
- _PyCFunction_CAST (varpos_array_no_fastcall ),
1620
- METH_VARARGS |METH_KEYWORDS |METH_CLASS , "" },
1621
- {"posonly_varpos_array_no_fastcall" ,
1622
- _PyCFunction_CAST (posonly_varpos_array_no_fastcall ),
1623
- METH_VARARGS |METH_KEYWORDS |METH_CLASS , "" },
1624
- {"posonly_req_opt_varpos_array_no_fastcall" ,
1625
- _PyCFunction_CAST (posonly_req_opt_varpos_array_no_fastcall ),
1626
- METH_VARARGS |METH_KEYWORDS |METH_CLASS , "" },
1627
- {"posonly_poskw_varpos_array_no_fastcall" ,
1628
- _PyCFunction_CAST (posonly_poskw_varpos_array_no_fastcall ),
1629
- METH_VARARGS |METH_KEYWORDS |METH_CLASS , "" },
1670
+ _TESTCLINIC_TESTCLASS_VARPOS_NO_FASTCALL_METHODDEF
1671
+ _TESTCLINIC_TESTCLASS_POSONLY_VARPOS_NO_FASTCALL_METHODDEF
1672
+ _TESTCLINIC_TESTCLASS_POSONLY_REQ_OPT_VARPOS_NO_FASTCALL_METHODDEF
1673
+ _TESTCLINIC_TESTCLASS_POSONLY_POSKW_VARPOS_NO_FASTCALL_METHODDEF
1674
+
1675
+ _TESTCLINIC_TESTCLASS_VARPOS_ARRAY_NO_FASTCALL_METHODDEF
1676
+ _TESTCLINIC_TESTCLASS_POSONLY_VARPOS_ARRAY_NO_FASTCALL_METHODDEF
1677
+ _TESTCLINIC_TESTCLASS_POSONLY_REQ_OPT_VARPOS_ARRAY_NO_FASTCALL_METHODDEF
1678
+ _TESTCLINIC_TESTCLASS_POSONLY_POSKW_VARPOS_ARRAY_NO_FASTCALL_METHODDEF
1630
1679
1631
1680
{NULL , NULL }
1632
1681
};
0 commit comments