gh-115015: Argument Clinic: fix generated code for METH_METHOD methods without params (#115016)

This commit is contained in:
Erlend E. Aasland 2024-02-05 21:49:17 +01:00 committed by GitHub
parent 4aa4f0906d
commit 09096a1647
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
30 changed files with 153 additions and 68 deletions

View file

@ -3288,6 +3288,26 @@ class ClinicFunctionalTest(unittest.TestCase):
func = getattr(ac_tester, name)
self.assertEqual(func(), name)
def test_meth_method_no_params(self):
obj = ac_tester.TestClass()
meth = obj.meth_method_no_params
check = partial(self.assertRaisesRegex, TypeError, "no arguments")
check(meth, 1)
check(meth, a=1)
def test_meth_method_no_params_capi(self):
from _testcapi import pyobject_vectorcall
obj = ac_tester.TestClass()
meth = obj.meth_method_no_params
pyobject_vectorcall(meth, None, None)
pyobject_vectorcall(meth, (), None)
pyobject_vectorcall(meth, (), ())
pyobject_vectorcall(meth, None, ())
check = partial(self.assertRaisesRegex, TypeError, "no arguments")
check(pyobject_vectorcall, meth, (1,), None)
check(pyobject_vectorcall, meth, (1,), ("a",))
def test_depr_star_new(self):
cls = ac_tester.DeprStarNew
cls()