0
0
mirror of https://github.com/python/cpython.git synced 2024-11-24 08:52:25 +01:00

gh-122688: Add more tests for var-positional parameters in Argument Clinic (GH-122900)

This commit is contained in:
Serhiy Storchaka 2024-08-12 16:52:48 +03:00 committed by GitHub
parent 253c6a0b2f
commit f9ba1f35c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 426 additions and 152 deletions

View File

@ -3378,26 +3378,44 @@ class ClinicFunctionalTest(unittest.TestCase):
ac_tester.keyword_only_parameter(1)
self.assertEqual(ac_tester.keyword_only_parameter(a=1), (1,))
def test_posonly_vararg(self):
with self.assertRaises(TypeError):
ac_tester.posonly_vararg()
self.assertEqual(ac_tester.posonly_vararg(1, 2), (1, 2, ()))
self.assertEqual(ac_tester.posonly_vararg(1, b=2), (1, 2, ()))
self.assertEqual(ac_tester.posonly_vararg(1, 2, 3, 4), (1, 2, (3, 4)))
with self.assertRaises(TypeError):
ac_tester.posonly_vararg(b=4)
with self.assertRaises(TypeError):
ac_tester.posonly_vararg(1, 2, 3, b=4)
def test_varpos(self):
# fn(*args)
fn = ac_tester.varpos
self.assertEqual(fn(), ())
self.assertEqual(fn(1, 2), (1, 2))
def test_vararg(self):
with self.assertRaises(TypeError):
ac_tester.vararg()
with self.assertRaises(TypeError):
ac_tester.vararg(1, b=2)
self.assertEqual(ac_tester.vararg(1, 2, 3, 4), (1, (2, 3, 4)))
def test_posonly_varpos(self):
# fn(a, b, /, *args)
fn = ac_tester.posonly_varpos
self.assertRaises(TypeError, fn)
self.assertRaises(TypeError, fn, 1)
self.assertRaises(TypeError, fn, 1, b=2)
self.assertEqual(fn(1, 2), (1, 2, ()))
self.assertEqual(fn(1, 2, 3, 4), (1, 2, (3, 4)))
def test_vararg_with_default(self):
fn = ac_tester.vararg_with_default
def test_posonly_poskw_varpos(self):
# fn(a, /, b, *args)
fn = ac_tester.posonly_poskw_varpos
self.assertRaises(TypeError, fn)
self.assertEqual(fn(1, 2), (1, 2, ()))
self.assertEqual(fn(1, b=2), (1, 2, ()))
self.assertEqual(fn(1, 2, 3, 4), (1, 2, (3, 4)))
self.assertRaises(TypeError, fn, b=4)
self.assertRaises(TypeError, fn, 1, 2, 3, b=4)
def test_poskw_varpos(self):
# fn(a, *args)
fn = ac_tester.poskw_varpos
self.assertRaises(TypeError, fn)
self.assertRaises(TypeError, fn, 1, b=2)
self.assertEqual(fn(a=1), (1, ()))
self.assertRaises(TypeError, fn, 1, a=2)
self.assertEqual(fn(1), (1, ()))
self.assertEqual(fn(1, 2, 3, 4), (1, (2, 3, 4)))
def test_poskw_varpos_kwonly_opt(self):
# fn(a, *args, b=False)
fn = ac_tester.poskw_varpos_kwonly_opt
self.assertRaises(TypeError, fn)
self.assertRaises(TypeError, fn, 1, a=2)
self.assertEqual(fn(1, b=2), (1, (), True))
@ -3406,35 +3424,38 @@ class ClinicFunctionalTest(unittest.TestCase):
self.assertEqual(fn(a=1), (1, (), False))
self.assertEqual(fn(a=1, b=2), (1, (), True))
def test_vararg_with_default2(self):
fn = ac_tester.vararg_with_default2
def test_poskw_varpos_kwonly_opt2(self):
# fn(a, *args, b=False, c=False)
fn = ac_tester.poskw_varpos_kwonly_opt2
self.assertRaises(TypeError, fn)
self.assertRaises(TypeError, fn, 1, a=2)
self.assertEqual(fn(1, b=2), (1, (), 2, None))
self.assertEqual(fn(1, b=2), (1, (), 2, False))
self.assertEqual(fn(1, b=2, c=3), (1, (), 2, 3))
self.assertEqual(fn(1, 2, 3), (1, (2, 3), None, None))
self.assertEqual(fn(1, 2, 3, b=4), (1, (2, 3), 4, None))
self.assertEqual(fn(1, 2, 3), (1, (2, 3), False, False))
self.assertEqual(fn(1, 2, 3, b=4), (1, (2, 3), 4, False))
self.assertEqual(fn(1, 2, 3, b=4, c=5), (1, (2, 3), 4, 5))
self.assertEqual(fn(a=1), (1, (), None, None))
self.assertEqual(fn(a=1, b=2), (1, (), 2, None))
self.assertEqual(fn(a=1), (1, (), False, False))
self.assertEqual(fn(a=1, b=2), (1, (), 2, False))
self.assertEqual(fn(a=1, b=2, c=3), (1, (), 2, 3))
def test_vararg_with_only_defaults(self):
self.assertEqual(ac_tester.vararg_with_only_defaults(), ((), None))
self.assertEqual(ac_tester.vararg_with_only_defaults(b=2), ((), 2))
self.assertEqual(ac_tester.vararg_with_only_defaults(1, b=2), ((1, ), 2))
self.assertEqual(ac_tester.vararg_with_only_defaults(1, 2, 3, 4), ((1, 2, 3, 4), None))
self.assertEqual(ac_tester.vararg_with_only_defaults(1, 2, 3, 4, b=5), ((1, 2, 3, 4), 5))
def test_varpos_kwonly_opt(self):
# fn(*args, b=False)
fn = ac_tester.varpos_kwonly_opt
self.assertEqual(fn(), ((), False))
self.assertEqual(fn(b=2), ((), 2))
self.assertEqual(fn(1, b=2), ((1, ), 2))
self.assertEqual(fn(1, 2, 3, 4), ((1, 2, 3, 4), False))
self.assertEqual(fn(1, 2, 3, 4, b=5), ((1, 2, 3, 4), 5))
def test_vararg_kwonly_req_opt(self):
fn = ac_tester.vararg_kwonly_req_opt
def test_varpos_kwonly_req_opt(self):
fn = ac_tester.varpos_kwonly_req_opt
self.assertRaises(TypeError, fn)
self.assertEqual(fn(a=1), ((), 1, None, None))
self.assertEqual(fn(a=1, b=2), ((), 1, 2, None))
self.assertEqual(fn(a=1), ((), 1, False, False))
self.assertEqual(fn(a=1, b=2), ((), 1, 2, False))
self.assertEqual(fn(a=1, b=2, c=3), ((), 1, 2, 3))
self.assertRaises(TypeError, fn, 1)
self.assertEqual(fn(1, a=2), ((1,), 2, None, None))
self.assertEqual(fn(1, a=2, b=3), ((1,), 2, 3, None))
self.assertEqual(fn(1, a=2), ((1,), 2, False, False))
self.assertEqual(fn(1, a=2, b=3), ((1,), 2, 3, False))
self.assertEqual(fn(1, a=2, b=3, c=4), ((1,), 2, 3, 4))
def test_gh_32092_oob(self):
@ -3459,35 +3480,19 @@ class ClinicFunctionalTest(unittest.TestCase):
ac_tester.gh_99240_double_free('a', '\0b')
def test_null_or_tuple_for_varargs(self):
# fn(name, *constraints, covariant=False)
fn = ac_tester.null_or_tuple_for_varargs
# All of these should not crash:
valid_args_for_test = [
(('a',), {},
('a', (), False)),
(('a', 1, 2, 3), {'covariant': True},
('a', (1, 2, 3), True)),
((), {'name': 'a'},
('a', (), False)),
((), {'name': 'a', 'covariant': True},
('a', (), True)),
((), {'covariant': True, 'name': 'a'},
('a', (), True)),
]
for args, kwargs, expected in valid_args_for_test:
with self.subTest(args=args, kwargs=kwargs):
self.assertEqual(
ac_tester.null_or_tuple_for_varargs(*args, **kwargs),
expected,
)
self.assertEqual(fn('a'), ('a', (), False))
self.assertEqual(fn('a', 1, 2, 3, covariant=True), ('a', (1, 2, 3), True))
self.assertEqual(fn(name='a'), ('a', (), False))
self.assertEqual(fn(name='a', covariant=True), ('a', (), True))
self.assertEqual(fn(covariant=True, name='a'), ('a', (), True))
def test_null_or_tuple_for_varargs_error(self):
with self.assertRaises(TypeError):
ac_tester.null_or_tuple_for_varargs(covariant=True)
with self.assertRaises(TypeError):
ac_tester.null_or_tuple_for_varargs(1, name='a')
with self.assertRaises(TypeError):
ac_tester.null_or_tuple_for_varargs(1, 2, 3, name='a', covariant=True)
with self.assertRaises(TypeError):
ac_tester.null_or_tuple_for_varargs(1, 2, 3, covariant=True, name='a')
self.assertRaises(TypeError, fn, covariant=True)
self.assertRaises(TypeError, fn, 1, name='a')
self.assertRaises(TypeError, fn, 1, 2, 3, name='a', covariant=True)
self.assertRaises(TypeError, fn, 1, 2, 3, covariant=True, name='a')
def test_cloned_func_exception_message(self):
incorrect_arg = -1 # f1() and f2() accept a single str
@ -3546,6 +3551,34 @@ class ClinicFunctionalTest(unittest.TestCase):
with self.assertRaises(TypeError):
obj.get_defining_class_arg("arg1", "arg2")
def test_defclass_varpos(self):
# fn(*args)
cls = ac_tester.TestClass
obj = cls()
fn = obj.defclass_varpos
self.assertEqual(fn(), (cls, ()))
self.assertEqual(fn(1, 2), (cls, (1, 2)))
fn = cls.defclass_varpos
self.assertRaises(TypeError, fn)
self.assertEqual(fn(obj), (cls, ()))
self.assertEqual(fn(obj, 1, 2), (cls, (1, 2)))
def test_defclass_posonly_varpos(self):
# fn(a, b, /, *args)
cls = ac_tester.TestClass
obj = cls()
fn = obj.defclass_posonly_varpos
self.assertRaises(TypeError, fn)
self.assertRaises(TypeError, fn, 1)
self.assertEqual(fn(1, 2), (cls, 1, 2, ()))
self.assertEqual(fn(1, 2, 3, 4), (cls, 1, 2, (3, 4)))
fn = cls.defclass_posonly_varpos
self.assertRaises(TypeError, fn)
self.assertRaises(TypeError, fn, obj)
self.assertRaises(TypeError, fn, obj, 1)
self.assertEqual(fn(obj, 1, 2), (cls, 1, 2, ()))
self.assertEqual(fn(obj, 1, 2, 3, 4), (cls, 1, 2, (3, 4)))
def test_depr_star_new(self):
cls = ac_tester.DeprStarNew
cls()

View File

@ -963,7 +963,41 @@ keyword_only_parameter_impl(PyObject *module, PyObject *a)
/*[clinic input]
posonly_vararg
varpos
*args: object
[clinic start generated code]*/
static PyObject *
varpos_impl(PyObject *module, PyObject *args)
/*[clinic end generated code: output=7b0b9545872bdca4 input=f87cd674145d394c]*/
{
return Py_NewRef(args);
}
/*[clinic input]
posonly_varpos
a: object
b: object
/
*args: object
[clinic start generated code]*/
static PyObject *
posonly_varpos_impl(PyObject *module, PyObject *a, PyObject *b,
PyObject *args)
/*[clinic end generated code: output=5dae5eb2a0d623cd input=c9fd7895cfbaabba]*/
{
return pack_arguments_newref(3, a, b, args);
}
/*[clinic input]
posonly_poskw_varpos
a: object
/
@ -973,16 +1007,16 @@ posonly_vararg
[clinic start generated code]*/
static PyObject *
posonly_vararg_impl(PyObject *module, PyObject *a, PyObject *b,
PyObject *args)
/*[clinic end generated code: output=ee6713acda6b954e input=783427fe7ec2b67a]*/
posonly_poskw_varpos_impl(PyObject *module, PyObject *a, PyObject *b,
PyObject *args)
/*[clinic end generated code: output=bffdb7649941c939 input=b3d7a734e0625f68]*/
{
return pack_arguments_newref(3, a, b, args);
}
/*[clinic input]
vararg
poskw_varpos
a: object
*args: object
@ -990,15 +1024,15 @@ vararg
[clinic start generated code]*/
static PyObject *
vararg_impl(PyObject *module, PyObject *a, PyObject *args)
/*[clinic end generated code: output=91ab7a0efc52dd5e input=02c0f772d05f591e]*/
poskw_varpos_impl(PyObject *module, PyObject *a, PyObject *args)
/*[clinic end generated code: output=2413ddfb5ef22794 input=a1dff12d00422484]*/
{
return pack_arguments_newref(2, a, args);
}
/*[clinic input]
vararg_with_default
poskw_varpos_kwonly_opt
a: object
*args: object
@ -1007,9 +1041,9 @@ vararg_with_default
[clinic start generated code]*/
static PyObject *
vararg_with_default_impl(PyObject *module, PyObject *a, PyObject *args,
int b)
/*[clinic end generated code: output=182c01035958ce92 input=68cafa6a79f89e36]*/
poskw_varpos_kwonly_opt_impl(PyObject *module, PyObject *a, PyObject *args,
int b)
/*[clinic end generated code: output=f36d35ba6133463b input=1721d43dc5f6d856]*/
{
PyObject *obj_b = b ? Py_True : Py_False;
return pack_arguments_newref(3, a, args, obj_b);
@ -1017,54 +1051,54 @@ vararg_with_default_impl(PyObject *module, PyObject *a, PyObject *args,
/*[clinic input]
vararg_with_default2
poskw_varpos_kwonly_opt2
a: object
*args: object
b: object = None
c: object = None
b: object = False
c: object = False
[clinic start generated code]*/
static PyObject *
vararg_with_default2_impl(PyObject *module, PyObject *a, PyObject *args,
PyObject *b, PyObject *c)
/*[clinic end generated code: output=a0fb7c37796e2129 input=59fb22f5f0a8925f]*/
poskw_varpos_kwonly_opt2_impl(PyObject *module, PyObject *a, PyObject *args,
PyObject *b, PyObject *c)
/*[clinic end generated code: output=846cef62c6c40463 input=bb4b8d1577a8a408]*/
{
return pack_arguments_newref(4, a, args, b, c);
}
/*[clinic input]
vararg_with_only_defaults
varpos_kwonly_opt
*args: object
b: object = None
b: object = False
[clinic start generated code]*/
static PyObject *
vararg_with_only_defaults_impl(PyObject *module, PyObject *args, PyObject *b)
/*[clinic end generated code: output=c06b1826d91f2f7b input=678c069bc67550e1]*/
varpos_kwonly_opt_impl(PyObject *module, PyObject *args, PyObject *b)
/*[clinic end generated code: output=3b7bf98b091f5731 input=380fb00deec847e8]*/
{
return pack_arguments_newref(2, args, b);
}
/*[clinic input]
vararg_kwonly_req_opt
varpos_kwonly_req_opt
*args: object
a: object
b: object = None
c: object = None
b: object = False
c: object = False
[clinic start generated code]*/
static PyObject *
vararg_kwonly_req_opt_impl(PyObject *module, PyObject *args, PyObject *a,
varpos_kwonly_req_opt_impl(PyObject *module, PyObject *args, PyObject *a,
PyObject *b, PyObject *c)
/*[clinic end generated code: output=54694a99c3da370a input=b0d8bf09e540d400]*/
/*[clinic end generated code: output=165274e1fd037ae9 input=530794afd0690c22]*/
{
return pack_arguments_newref(4, args, a, b, c);
}
@ -1266,9 +1300,44 @@ _testclinic_TestClass_get_defining_class_arg_impl(PyObject *self,
return PyTuple_Pack(2, cls, arg);
}
/*[clinic input]
_testclinic.TestClass.defclass_varpos
cls: defining_class
*args: object
[clinic start generated code]*/
static PyObject *
_testclinic_TestClass_defclass_varpos_impl(PyObject *self, PyTypeObject *cls,
PyObject *args)
/*[clinic end generated code: output=fad33f2d3a8d778d input=47071dcda393a7e1]*/
{
return PyTuple_Pack(2, cls, args);
}
/*[clinic input]
_testclinic.TestClass.defclass_posonly_varpos
cls: defining_class
a: object
b: object
/
*args: object
[clinic start generated code]*/
static PyObject *
_testclinic_TestClass_defclass_posonly_varpos_impl(PyObject *self,
PyTypeObject *cls,
PyObject *a, PyObject *b,
PyObject *args)
/*[clinic end generated code: output=1740fcf48d230b07 input=40f2e56286d4a7ef]*/
{
return pack_arguments_newref(4, cls, a, b, args);
}
static struct PyMethodDef test_class_methods[] = {
_TESTCLINIC_TESTCLASS_GET_DEFINING_CLASS_METHODDEF
_TESTCLINIC_TESTCLASS_GET_DEFINING_CLASS_ARG_METHODDEF
_TESTCLINIC_TESTCLASS_DEFCLASS_VARPOS_METHODDEF
_TESTCLINIC_TESTCLASS_DEFCLASS_POSONLY_VARPOS_METHODDEF
{NULL, NULL}
};
@ -1907,6 +1976,7 @@ static PyMethodDef tester_methods[] = {
STR_CONVERTER_METHODDEF
STR_CONVERTER_ENCODING_METHODDEF
PY_BUFFER_CONVERTER_METHODDEF
KEYWORDS_METHODDEF
KEYWORDS_KWONLY_METHODDEF
KEYWORDS_OPT_METHODDEF
@ -1923,17 +1993,21 @@ static PyMethodDef tester_methods[] = {
POSONLY_KEYWORDS_OPT_KWONLY_OPT_METHODDEF
POSONLY_OPT_KEYWORDS_OPT_KWONLY_OPT_METHODDEF
KEYWORD_ONLY_PARAMETER_METHODDEF
POSONLY_VARARG_METHODDEF
VARARG_METHODDEF
VARARG_WITH_DEFAULT_METHODDEF
VARARG_WITH_DEFAULT2_METHODDEF
VARARG_WITH_ONLY_DEFAULTS_METHODDEF
VARARG_KWONLY_REQ_OPT_METHODDEF
VARPOS_METHODDEF
POSONLY_VARPOS_METHODDEF
POSONLY_POSKW_VARPOS_METHODDEF
POSKW_VARPOS_METHODDEF
POSKW_VARPOS_KWONLY_OPT_METHODDEF
POSKW_VARPOS_KWONLY_OPT2_METHODDEF
VARPOS_KWONLY_OPT_METHODDEF
VARPOS_KWONLY_REQ_OPT_METHODDEF
GH_32092_OOB_METHODDEF
GH_32092_KW_PASS_METHODDEF
GH_99233_REFCOUNT_METHODDEF
GH_99240_DOUBLE_FREE_METHODDEF
NULL_OR_TUPLE_FOR_VARARGS_METHODDEF
CLONE_F1_METHODDEF
CLONE_F2_METHODDEF
CLONE_WITH_CONV_F1_METHODDEF

View File

@ -2521,20 +2521,93 @@ exit:
return return_value;
}
PyDoc_STRVAR(posonly_vararg__doc__,
"posonly_vararg($module, a, /, b, *args)\n"
PyDoc_STRVAR(varpos__doc__,
"varpos($module, /, *args)\n"
"--\n"
"\n");
#define POSONLY_VARARG_METHODDEF \
{"posonly_vararg", _PyCFunction_CAST(posonly_vararg), METH_FASTCALL|METH_KEYWORDS, posonly_vararg__doc__},
#define VARPOS_METHODDEF \
{"varpos", _PyCFunction_CAST(varpos), METH_FASTCALL, varpos__doc__},
static PyObject *
posonly_vararg_impl(PyObject *module, PyObject *a, PyObject *b,
varpos_impl(PyObject *module, PyObject *args);
static PyObject *
varpos(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
PyObject *__clinic_args = NULL;
if (!_PyArg_CheckPositional("varpos", nargs, 0, PY_SSIZE_T_MAX)) {
goto exit;
}
__clinic_args = PyTuple_New(nargs - 0);
if (!__clinic_args) {
goto exit;
}
for (Py_ssize_t i = 0; i < nargs - 0; ++i) {
PyTuple_SET_ITEM(__clinic_args, i, Py_NewRef(args[0 + i]));
}
return_value = varpos_impl(module, __clinic_args);
exit:
Py_XDECREF(__clinic_args);
return return_value;
}
PyDoc_STRVAR(posonly_varpos__doc__,
"posonly_varpos($module, a, b, /, *args)\n"
"--\n"
"\n");
#define POSONLY_VARPOS_METHODDEF \
{"posonly_varpos", _PyCFunction_CAST(posonly_varpos), METH_FASTCALL, posonly_varpos__doc__},
static PyObject *
posonly_varpos_impl(PyObject *module, PyObject *a, PyObject *b,
PyObject *args);
static PyObject *
posonly_vararg(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
posonly_varpos(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
{
PyObject *return_value = NULL;
PyObject *a;
PyObject *b;
PyObject *__clinic_args = NULL;
if (!_PyArg_CheckPositional("posonly_varpos", nargs, 2, PY_SSIZE_T_MAX)) {
goto exit;
}
a = args[0];
b = args[1];
__clinic_args = PyTuple_New(nargs - 2);
if (!__clinic_args) {
goto exit;
}
for (Py_ssize_t i = 0; i < nargs - 2; ++i) {
PyTuple_SET_ITEM(__clinic_args, i, Py_NewRef(args[2 + i]));
}
return_value = posonly_varpos_impl(module, a, b, __clinic_args);
exit:
Py_XDECREF(__clinic_args);
return return_value;
}
PyDoc_STRVAR(posonly_poskw_varpos__doc__,
"posonly_poskw_varpos($module, a, /, b, *args)\n"
"--\n"
"\n");
#define POSONLY_POSKW_VARPOS_METHODDEF \
{"posonly_poskw_varpos", _PyCFunction_CAST(posonly_poskw_varpos), METH_FASTCALL|METH_KEYWORDS, posonly_poskw_varpos__doc__},
static PyObject *
posonly_poskw_varpos_impl(PyObject *module, PyObject *a, PyObject *b,
PyObject *args);
static PyObject *
posonly_poskw_varpos(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
@ -2558,7 +2631,7 @@ posonly_vararg(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje
static const char * const _keywords[] = {"", "b", NULL};
static _PyArg_Parser _parser = {
.keywords = _keywords,
.fname = "posonly_vararg",
.fname = "posonly_poskw_varpos",
.kwtuple = KWTUPLE,
};
#undef KWTUPLE
@ -2574,26 +2647,26 @@ posonly_vararg(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObje
a = args[0];
b = args[1];
__clinic_args = args[2];
return_value = posonly_vararg_impl(module, a, b, __clinic_args);
return_value = posonly_poskw_varpos_impl(module, a, b, __clinic_args);
exit:
Py_XDECREF(__clinic_args);
return return_value;
}
PyDoc_STRVAR(vararg__doc__,
"vararg($module, /, a, *args)\n"
PyDoc_STRVAR(poskw_varpos__doc__,
"poskw_varpos($module, /, a, *args)\n"
"--\n"
"\n");
#define VARARG_METHODDEF \
{"vararg", _PyCFunction_CAST(vararg), METH_FASTCALL|METH_KEYWORDS, vararg__doc__},
#define POSKW_VARPOS_METHODDEF \
{"poskw_varpos", _PyCFunction_CAST(poskw_varpos), METH_FASTCALL|METH_KEYWORDS, poskw_varpos__doc__},
static PyObject *
vararg_impl(PyObject *module, PyObject *a, PyObject *args);
poskw_varpos_impl(PyObject *module, PyObject *a, PyObject *args);
static PyObject *
vararg(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
poskw_varpos(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
@ -2617,7 +2690,7 @@ vararg(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwna
static const char * const _keywords[] = {"a", NULL};
static _PyArg_Parser _parser = {
.keywords = _keywords,
.fname = "vararg",
.fname = "poskw_varpos",
.kwtuple = KWTUPLE,
};
#undef KWTUPLE
@ -2631,27 +2704,27 @@ vararg(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwna
}
a = args[0];
__clinic_args = args[1];
return_value = vararg_impl(module, a, __clinic_args);
return_value = poskw_varpos_impl(module, a, __clinic_args);
exit:
Py_XDECREF(__clinic_args);
return return_value;
}
PyDoc_STRVAR(vararg_with_default__doc__,
"vararg_with_default($module, /, a, *args, b=False)\n"
PyDoc_STRVAR(poskw_varpos_kwonly_opt__doc__,
"poskw_varpos_kwonly_opt($module, /, a, *args, b=False)\n"
"--\n"
"\n");
#define VARARG_WITH_DEFAULT_METHODDEF \
{"vararg_with_default", _PyCFunction_CAST(vararg_with_default), METH_FASTCALL|METH_KEYWORDS, vararg_with_default__doc__},
#define POSKW_VARPOS_KWONLY_OPT_METHODDEF \
{"poskw_varpos_kwonly_opt", _PyCFunction_CAST(poskw_varpos_kwonly_opt), METH_FASTCALL|METH_KEYWORDS, poskw_varpos_kwonly_opt__doc__},
static PyObject *
vararg_with_default_impl(PyObject *module, PyObject *a, PyObject *args,
int b);
poskw_varpos_kwonly_opt_impl(PyObject *module, PyObject *a, PyObject *args,
int b);
static PyObject *
vararg_with_default(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
poskw_varpos_kwonly_opt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
@ -2675,7 +2748,7 @@ vararg_with_default(PyObject *module, PyObject *const *args, Py_ssize_t nargs, P
static const char * const _keywords[] = {"a", "b", NULL};
static _PyArg_Parser _parser = {
.keywords = _keywords,
.fname = "vararg_with_default",
.fname = "poskw_varpos_kwonly_opt",
.kwtuple = KWTUPLE,
};
#undef KWTUPLE
@ -2699,27 +2772,27 @@ vararg_with_default(PyObject *module, PyObject *const *args, Py_ssize_t nargs, P
goto exit;
}
skip_optional_kwonly:
return_value = vararg_with_default_impl(module, a, __clinic_args, b);
return_value = poskw_varpos_kwonly_opt_impl(module, a, __clinic_args, b);
exit:
Py_XDECREF(__clinic_args);
return return_value;
}
PyDoc_STRVAR(vararg_with_default2__doc__,
"vararg_with_default2($module, /, a, *args, b=None, c=None)\n"
PyDoc_STRVAR(poskw_varpos_kwonly_opt2__doc__,
"poskw_varpos_kwonly_opt2($module, /, a, *args, b=False, c=False)\n"
"--\n"
"\n");
#define VARARG_WITH_DEFAULT2_METHODDEF \
{"vararg_with_default2", _PyCFunction_CAST(vararg_with_default2), METH_FASTCALL|METH_KEYWORDS, vararg_with_default2__doc__},
#define POSKW_VARPOS_KWONLY_OPT2_METHODDEF \
{"poskw_varpos_kwonly_opt2", _PyCFunction_CAST(poskw_varpos_kwonly_opt2), METH_FASTCALL|METH_KEYWORDS, poskw_varpos_kwonly_opt2__doc__},
static PyObject *
vararg_with_default2_impl(PyObject *module, PyObject *a, PyObject *args,
PyObject *b, PyObject *c);
poskw_varpos_kwonly_opt2_impl(PyObject *module, PyObject *a, PyObject *args,
PyObject *b, PyObject *c);
static PyObject *
vararg_with_default2(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
poskw_varpos_kwonly_opt2(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
@ -2743,7 +2816,7 @@ vararg_with_default2(PyObject *module, PyObject *const *args, Py_ssize_t nargs,
static const char * const _keywords[] = {"a", "b", "c", NULL};
static _PyArg_Parser _parser = {
.keywords = _keywords,
.fname = "vararg_with_default2",
.fname = "poskw_varpos_kwonly_opt2",
.kwtuple = KWTUPLE,
};
#undef KWTUPLE
@ -2751,8 +2824,8 @@ vararg_with_default2(PyObject *module, PyObject *const *args, Py_ssize_t nargs,
Py_ssize_t noptargs = Py_MIN(nargs, 1) + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
PyObject *a;
PyObject *__clinic_args = NULL;
PyObject *b = Py_None;
PyObject *c = Py_None;
PyObject *b = Py_False;
PyObject *c = Py_False;
args = _PyArg_UnpackKeywordsWithVararg(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, 1, argsbuf);
if (!args) {
@ -2771,26 +2844,26 @@ vararg_with_default2(PyObject *module, PyObject *const *args, Py_ssize_t nargs,
}
c = args[3];
skip_optional_kwonly:
return_value = vararg_with_default2_impl(module, a, __clinic_args, b, c);
return_value = poskw_varpos_kwonly_opt2_impl(module, a, __clinic_args, b, c);
exit:
Py_XDECREF(__clinic_args);
return return_value;
}
PyDoc_STRVAR(vararg_with_only_defaults__doc__,
"vararg_with_only_defaults($module, /, *args, b=None)\n"
PyDoc_STRVAR(varpos_kwonly_opt__doc__,
"varpos_kwonly_opt($module, /, *args, b=False)\n"
"--\n"
"\n");
#define VARARG_WITH_ONLY_DEFAULTS_METHODDEF \
{"vararg_with_only_defaults", _PyCFunction_CAST(vararg_with_only_defaults), METH_FASTCALL|METH_KEYWORDS, vararg_with_only_defaults__doc__},
#define VARPOS_KWONLY_OPT_METHODDEF \
{"varpos_kwonly_opt", _PyCFunction_CAST(varpos_kwonly_opt), METH_FASTCALL|METH_KEYWORDS, varpos_kwonly_opt__doc__},
static PyObject *
vararg_with_only_defaults_impl(PyObject *module, PyObject *args, PyObject *b);
varpos_kwonly_opt_impl(PyObject *module, PyObject *args, PyObject *b);
static PyObject *
vararg_with_only_defaults(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
varpos_kwonly_opt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
@ -2814,14 +2887,14 @@ vararg_with_only_defaults(PyObject *module, PyObject *const *args, Py_ssize_t na
static const char * const _keywords[] = {"b", NULL};
static _PyArg_Parser _parser = {
.keywords = _keywords,
.fname = "vararg_with_only_defaults",
.fname = "varpos_kwonly_opt",
.kwtuple = KWTUPLE,
};
#undef KWTUPLE
PyObject *argsbuf[2];
Py_ssize_t noptargs = 0 + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
PyObject *__clinic_args = NULL;
PyObject *b = Py_None;
PyObject *b = Py_False;
args = _PyArg_UnpackKeywordsWithVararg(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, 0, argsbuf);
if (!args) {
@ -2833,27 +2906,27 @@ vararg_with_only_defaults(PyObject *module, PyObject *const *args, Py_ssize_t na
}
b = args[1];
skip_optional_kwonly:
return_value = vararg_with_only_defaults_impl(module, __clinic_args, b);
return_value = varpos_kwonly_opt_impl(module, __clinic_args, b);
exit:
Py_XDECREF(__clinic_args);
return return_value;
}
PyDoc_STRVAR(vararg_kwonly_req_opt__doc__,
"vararg_kwonly_req_opt($module, /, *args, a, b=None, c=None)\n"
PyDoc_STRVAR(varpos_kwonly_req_opt__doc__,
"varpos_kwonly_req_opt($module, /, *args, a, b=False, c=False)\n"
"--\n"
"\n");
#define VARARG_KWONLY_REQ_OPT_METHODDEF \
{"vararg_kwonly_req_opt", _PyCFunction_CAST(vararg_kwonly_req_opt), METH_FASTCALL|METH_KEYWORDS, vararg_kwonly_req_opt__doc__},
#define VARPOS_KWONLY_REQ_OPT_METHODDEF \
{"varpos_kwonly_req_opt", _PyCFunction_CAST(varpos_kwonly_req_opt), METH_FASTCALL|METH_KEYWORDS, varpos_kwonly_req_opt__doc__},
static PyObject *
vararg_kwonly_req_opt_impl(PyObject *module, PyObject *args, PyObject *a,
varpos_kwonly_req_opt_impl(PyObject *module, PyObject *args, PyObject *a,
PyObject *b, PyObject *c);
static PyObject *
vararg_kwonly_req_opt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
varpos_kwonly_req_opt(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
@ -2877,7 +2950,7 @@ vararg_kwonly_req_opt(PyObject *module, PyObject *const *args, Py_ssize_t nargs,
static const char * const _keywords[] = {"a", "b", "c", NULL};
static _PyArg_Parser _parser = {
.keywords = _keywords,
.fname = "vararg_kwonly_req_opt",
.fname = "varpos_kwonly_req_opt",
.kwtuple = KWTUPLE,
};
#undef KWTUPLE
@ -2885,8 +2958,8 @@ vararg_kwonly_req_opt(PyObject *module, PyObject *const *args, Py_ssize_t nargs,
Py_ssize_t noptargs = 0 + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
PyObject *__clinic_args = NULL;
PyObject *a;
PyObject *b = Py_None;
PyObject *c = Py_None;
PyObject *b = Py_False;
PyObject *c = Py_False;
args = _PyArg_UnpackKeywordsWithVararg(args, nargs, NULL, kwnames, &_parser, 0, 0, 1, 0, argsbuf);
if (!args) {
@ -2905,7 +2978,7 @@ vararg_kwonly_req_opt(PyObject *module, PyObject *const *args, Py_ssize_t nargs,
}
c = args[3];
skip_optional_kwonly:
return_value = vararg_kwonly_req_opt_impl(module, __clinic_args, a, b, c);
return_value = varpos_kwonly_req_opt_impl(module, __clinic_args, a, b, c);
exit:
Py_XDECREF(__clinic_args);
@ -3526,4 +3599,98 @@ _testclinic_TestClass_get_defining_class_arg(PyObject *self, PyTypeObject *cls,
exit:
return return_value;
}
/*[clinic end generated code: output=cacfbed4b2e50ba6 input=a9049054013a1b77]*/
PyDoc_STRVAR(_testclinic_TestClass_defclass_varpos__doc__,
"defclass_varpos($self, /, *args)\n"
"--\n"
"\n");
#define _TESTCLINIC_TESTCLASS_DEFCLASS_VARPOS_METHODDEF \
{"defclass_varpos", _PyCFunction_CAST(_testclinic_TestClass_defclass_varpos), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testclinic_TestClass_defclass_varpos__doc__},
static PyObject *
_testclinic_TestClass_defclass_varpos_impl(PyObject *self, PyTypeObject *cls,
PyObject *args);
static PyObject *
_testclinic_TestClass_defclass_varpos(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
#else
# define KWTUPLE NULL
#endif
static const char * const _keywords[] = { NULL};
static _PyArg_Parser _parser = {
.keywords = _keywords,
.fname = "defclass_varpos",
.kwtuple = KWTUPLE,
};
#undef KWTUPLE
PyObject *argsbuf[1];
PyObject *__clinic_args = NULL;
args = _PyArg_UnpackKeywordsWithVararg(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, 0, argsbuf);
if (!args) {
goto exit;
}
__clinic_args = args[0];
return_value = _testclinic_TestClass_defclass_varpos_impl(self, cls, __clinic_args);
exit:
Py_XDECREF(__clinic_args);
return return_value;
}
PyDoc_STRVAR(_testclinic_TestClass_defclass_posonly_varpos__doc__,
"defclass_posonly_varpos($self, a, b, /, *args)\n"
"--\n"
"\n");
#define _TESTCLINIC_TESTCLASS_DEFCLASS_POSONLY_VARPOS_METHODDEF \
{"defclass_posonly_varpos", _PyCFunction_CAST(_testclinic_TestClass_defclass_posonly_varpos), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _testclinic_TestClass_defclass_posonly_varpos__doc__},
static PyObject *
_testclinic_TestClass_defclass_posonly_varpos_impl(PyObject *self,
PyTypeObject *cls,
PyObject *a, PyObject *b,
PyObject *args);
static PyObject *
_testclinic_TestClass_defclass_posonly_varpos(PyObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
#else
# define KWTUPLE NULL
#endif
static const char * const _keywords[] = {"", "", NULL};
static _PyArg_Parser _parser = {
.keywords = _keywords,
.fname = "defclass_posonly_varpos",
.kwtuple = KWTUPLE,
};
#undef KWTUPLE
PyObject *argsbuf[3];
PyObject *a;
PyObject *b;
PyObject *__clinic_args = NULL;
args = _PyArg_UnpackKeywordsWithVararg(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, 2, argsbuf);
if (!args) {
goto exit;
}
a = args[0];
b = args[1];
__clinic_args = args[2];
return_value = _testclinic_TestClass_defclass_posonly_varpos_impl(self, cls, a, b, __clinic_args);
exit:
Py_XDECREF(__clinic_args);
return return_value;
}
/*[clinic end generated code: output=76ecbb38c632bde8 input=a9049054013a1b77]*/