/*[clinic input]preserve[clinic start generated code]*/#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
# include"pycore_gc.h"// PyGC_Head# include"pycore_runtime.h"// _Py_ID()#endifPyDoc_STRVAR(func__doc__,
"func($module, /, a, b)\n""--\n""\n");
#defineFUNC_METHODDEF \
{"func", _PyCFunction_CAST(func), METH_FASTCALL|METH_KEYWORDS, func__doc__},
staticPyObject*func_impl(PyObject*module, PyObject*a, PyObject*b);
staticPyObject*func(PyObject*module, PyObject*const*args, Py_ssize_tnargs, PyObject*kwnames)
{
PyObject*return_value=NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
#defineNUM_KEYWORDS 2
staticstruct {
PyGC_Head_this_is_not_used;
PyObject_VAR_HEADPyObject*ob_item[NUM_KEYWORDS];
} _kwtuple= {
.ob_base=PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
.ob_item= { &_Py_ID(a), &_Py_ID(b), },
};
#undef NUM_KEYWORDS
#defineKWTUPLE (&_kwtuple.ob_base.ob_base)
#else// !Py_BUILD_CORE# defineKWTUPLE NULL
#endif// !Py_BUILD_COREstaticconstchar*const_keywords[] = {"a", "b", NULL};
static_PyArg_Parser_parser= {
.keywords=_keywords,
.fname="func",
.kwtuple=KWTUPLE,
};
#undef KWTUPLE
PyObject*argsbuf[2];
PyObject*a;
PyObject*b;
args=_PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
if (!args) {
goto exit;
}
a=args[0];
b=args[1];
return_value=func_impl(module, a, b);
exit:
returnreturn_value;
}
/*[clinic end generated code: output=e790cd95ffc517a0 input=a9049054013a1b77]*/
It seems like Argument Clinic generates code that define
Py_BUILD_COREand includes internal headers unconditionally; for example, a file with aMETH_Ofunction will have no need for those:Details
OTOH, a
METH_KEYWORDSfunction needs those:Details
Argument Clinic should check if those defines/includes are needed before generating the output.
Linked PRs
print_block()#108581