Skip to content

Commit 78a0644

Browse files
committed
Test both PyVectorcall_Call and _PyObject_Vectorcall; rename test functions
Test functions are renamed to reflect the C API they're testing.
1 parent c1f7a61 commit 78a0644

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

Lib/test/test_call.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,27 +435,27 @@ def test_vectorcall(self):
435435
for func, args, expected in self.CALLS_POSARGS:
436436
with self.subTest(func=func, args=args):
437437
# kwnames=NULL
438-
result = _testcapi.pyobject_fastcallkeywords(func, args, None)
438+
result = _testcapi.pyobject_vectorcall(func, args, None)
439439
self.check_result(result, expected)
440440

441441
# kwnames=()
442-
result = _testcapi.pyobject_fastcallkeywords(func, args, ())
442+
result = _testcapi.pyobject_vectorcall(func, args, ())
443443
self.check_result(result, expected)
444444

445445
if not args:
446446
# kwnames=NULL
447-
result = _testcapi.pyobject_fastcallkeywords(func, None, None)
447+
result = _testcapi.pyobject_vectorcall(func, None, None)
448448
self.check_result(result, expected)
449449

450450
# kwnames=()
451-
result = _testcapi.pyobject_fastcallkeywords(func, None, ())
451+
result = _testcapi.pyobject_vectorcall(func, None, ())
452452
self.check_result(result, expected)
453453

454454
for func, args, kwargs, expected in self.CALLS_KWARGS:
455455
with self.subTest(func=func, args=args, kwargs=kwargs):
456456
kwnames = tuple(kwargs.keys())
457457
args = args + tuple(kwargs.values())
458-
result = _testcapi.pyobject_fastcallkeywords(func, args, kwnames)
458+
result = _testcapi.pyobject_vectorcall(func, args, kwnames)
459459
self.check_result(result, expected)
460460

461461
def test_fastcall_clearing_dict(self):

Lib/test/test_capi.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,21 +499,29 @@ def test_vectorcall(self):
499499
(testfunction, (42,), {}, 42),
500500
(testfunction_kw, (42,), {"kw":None}, 42)]
501501

502-
from _testcapi import vectorcall
502+
from _testcapi import pyobject_vectorcall, pyvectorcall_call
503503
from types import MethodType
504504
from functools import partial
505+
506+
def vectorcall(func, args, kwargs=None):
507+
args = *args, *kwargs.values()
508+
kwnames = tuple(kwargs)
509+
return pyobject_vectorcall(func, args, kwnames)
510+
505511
for (func, args, kwargs, expected) in calls:
506512
with self.subTest(str(func)):
507513
args1 = args[1:]
508514
meth = MethodType(func, args[0])
509515
wrapped = partial(func)
510516
if not kwargs:
511517
self.assertEqual(expected, func(*args))
512-
self.assertEqual(expected, vectorcall(func, args))
518+
self.assertEqual(expected, pyobject_vectorcall(func, args, None))
519+
self.assertEqual(expected, pyvectorcall_call(func, args))
513520
self.assertEqual(expected, meth(*args1))
514521
self.assertEqual(expected, wrapped(*args))
515522
self.assertEqual(expected, func(*args, **kwargs))
516523
self.assertEqual(expected, vectorcall(func, args, kwargs))
524+
self.assertEqual(expected, pyvectorcall_call(func, args, kwargs))
517525
self.assertEqual(expected, meth(*args1, **kwargs))
518526
self.assertEqual(expected, wrapped(*args, **kwargs))
519527

Modules/_testcapimodule.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4713,7 +4713,7 @@ test_pyobject_fastcalldict(PyObject *self, PyObject *args)
47134713

47144714

47154715
static PyObject *
4716-
test_pyobject_fastcallkeywords(PyObject *self, PyObject *args)
4716+
test_pyobject_vectorcall(PyObject *self, PyObject *args)
47174717
{
47184718
PyObject *func, *func_args, *kwnames = NULL;
47194719
PyObject **stack;
@@ -4747,7 +4747,7 @@ test_pyobject_fastcallkeywords(PyObject *self, PyObject *args)
47474747

47484748

47494749
static PyObject *
4750-
vectorcall(PyObject *self, PyObject *args)
4750+
test_pyvectorcall_call(PyObject *self, PyObject *args)
47514751
{
47524752
PyObject *func;
47534753
PyObject *argstuple;
@@ -5254,8 +5254,8 @@ static PyMethodDef TestMethods[] = {
52545254
{"raise_SIGINT_then_send_None", raise_SIGINT_then_send_None, METH_VARARGS},
52555255
{"pyobject_fastcall", test_pyobject_fastcall, METH_VARARGS},
52565256
{"pyobject_fastcalldict", test_pyobject_fastcalldict, METH_VARARGS},
5257-
{"pyobject_fastcallkeywords", test_pyobject_fastcallkeywords, METH_VARARGS},
5258-
{"vectorcall", vectorcall, METH_VARARGS},
5257+
{"pyobject_vectorcall", test_pyobject_vectorcall, METH_VARARGS},
5258+
{"pyvectorcall_call", test_pyvectorcall_call, METH_VARARGS},
52595259
{"stack_pointer", stack_pointer, METH_NOARGS},
52605260
#ifdef W_STOPCODE
52615261
{"W_STOPCODE", py_w_stopcode, METH_VARARGS},

0 commit comments

Comments
 (0)