mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
gh-132753: Argument Clinic: Fix support of c_default for the bool converter (GH-132754)
This commit is contained in:
parent
dc4a7077ac
commit
78cfee6f09
4 changed files with 86 additions and 2 deletions
|
@ -224,6 +224,25 @@ bool_converter_impl(PyObject *module, int a, int b, int c)
|
|||
}
|
||||
|
||||
|
||||
/*[clinic input]
|
||||
bool_converter_c_default
|
||||
|
||||
a: bool = True
|
||||
b: bool = False
|
||||
c: bool(c_default="-2") = True
|
||||
d: bool(c_default="-3") = x
|
||||
/
|
||||
|
||||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
bool_converter_c_default_impl(PyObject *module, int a, int b, int c, int d)
|
||||
/*[clinic end generated code: output=cf204382e1e4c30c input=185786302ab84081]*/
|
||||
{
|
||||
return Py_BuildValue("iiii", a, b, c, d);
|
||||
}
|
||||
|
||||
|
||||
/*[clinic input]
|
||||
char_converter
|
||||
|
||||
|
@ -2296,6 +2315,7 @@ static PyMethodDef tester_methods[] = {
|
|||
BYTE_ARRAY_OBJECT_CONVERTER_METHODDEF
|
||||
UNICODE_CONVERTER_METHODDEF
|
||||
BOOL_CONVERTER_METHODDEF
|
||||
BOOL_CONVERTER_C_DEFAULT_METHODDEF
|
||||
CHAR_CONVERTER_METHODDEF
|
||||
UNSIGNED_CHAR_CONVERTER_METHODDEF
|
||||
SHORT_CONVERTER_METHODDEF
|
||||
|
|
60
Modules/clinic/_testclinic.c.h
generated
60
Modules/clinic/_testclinic.c.h
generated
|
@ -195,6 +195,64 @@ exit:
|
|||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(bool_converter_c_default__doc__,
|
||||
"bool_converter_c_default($module, a=True, b=False, c=True, d=x, /)\n"
|
||||
"--\n"
|
||||
"\n");
|
||||
|
||||
#define BOOL_CONVERTER_C_DEFAULT_METHODDEF \
|
||||
{"bool_converter_c_default", _PyCFunction_CAST(bool_converter_c_default), METH_FASTCALL, bool_converter_c_default__doc__},
|
||||
|
||||
static PyObject *
|
||||
bool_converter_c_default_impl(PyObject *module, int a, int b, int c, int d);
|
||||
|
||||
static PyObject *
|
||||
bool_converter_c_default(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
int a = 1;
|
||||
int b = 0;
|
||||
int c = -2;
|
||||
int d = -3;
|
||||
|
||||
if (!_PyArg_CheckPositional("bool_converter_c_default", nargs, 0, 4)) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 1) {
|
||||
goto skip_optional;
|
||||
}
|
||||
a = PyObject_IsTrue(args[0]);
|
||||
if (a < 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 2) {
|
||||
goto skip_optional;
|
||||
}
|
||||
b = PyObject_IsTrue(args[1]);
|
||||
if (b < 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 3) {
|
||||
goto skip_optional;
|
||||
}
|
||||
c = PyObject_IsTrue(args[2]);
|
||||
if (c < 0) {
|
||||
goto exit;
|
||||
}
|
||||
if (nargs < 4) {
|
||||
goto skip_optional;
|
||||
}
|
||||
d = PyObject_IsTrue(args[3]);
|
||||
if (d < 0) {
|
||||
goto exit;
|
||||
}
|
||||
skip_optional:
|
||||
return_value = bool_converter_c_default_impl(module, a, b, c, d);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(char_converter__doc__,
|
||||
"char_converter($module, a=b\'A\', b=b\'\\x07\', c=b\'\\x08\', d=b\'\\t\', e=b\'\\n\',\n"
|
||||
" f=b\'\\x0b\', g=b\'\\x0c\', h=b\'\\r\', i=b\'\"\', j=b\"\'\", k=b\'?\',\n"
|
||||
|
@ -4423,4 +4481,4 @@ _testclinic_TestClass_posonly_poskw_varpos_array_no_fastcall(PyObject *type, PyO
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=ea0b8fb0949fa49f input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=b57b94aeba0882b4 input=a9049054013a1b77]*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue