mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
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:
parent
7f5afecfd7
commit
27f9491c60
8 changed files with 40 additions and 6 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue