gh-105107: Remove PyCFunction_Call() function (#105181)

* Keep the function in the stable ABI.
* Add unit tests on PyCFunction_Call() since it remains supported in
  the stable ABI.
This commit is contained in:
Victor Stinner 2023-06-01 11:25:55 +02:00 committed by GitHub
parent 7f5afecfd7
commit 27f9491c60
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 40 additions and 6 deletions

View file

@ -966,6 +966,7 @@ class TestRecursion(unittest.TestCase):
finally:
sys.setrecursionlimit(depth)
class TestFunctionWithManyArgs(unittest.TestCase):
def test_function_with_many_args(self):
for N in (10, 500, 1000):
@ -977,5 +978,24 @@ class TestFunctionWithManyArgs(unittest.TestCase):
self.assertEqual(l['f'](*range(N)), N//2)
@unittest.skipIf(_testcapi is None, 'need _testcapi')
class TestCAPI(unittest.TestCase):
def test_cfunction_call(self):
def func(*args, **kwargs):
return (args, kwargs)
# PyCFunction_Call() was removed in Python 3.13 API, but was kept in
# the stable ABI.
def PyCFunction_Call(func, *args, **kwargs):
if kwargs:
return _testcapi.pycfunction_call(func, args, kwargs)
else:
return _testcapi.pycfunction_call(func, args)
self.assertEqual(PyCFunction_Call(func), ((), {}))
self.assertEqual(PyCFunction_Call(func, 1, 2, 3), ((1, 2, 3), {}))
self.assertEqual(PyCFunction_Call(func, "arg", num=5), (("arg",), {'num': 5}))
if __name__ == "__main__":
unittest.main()