Inline argument docs

This commit is contained in:
Batuhan Taskaya 2020-03-15 06:49:37 +03:00
parent b56b135923
commit 445eaa5e3f
3 changed files with 22 additions and 20 deletions

View File

@ -1,2 +1,2 @@
Vararg (`*args`) notation support for Argument Clinic. Patch by Batuhan
Taskaya.
Added support for :term:`var-positional` parameter in Argument Clinic.
Patch by Batuhan Taskaya.

View File

@ -1827,27 +1827,26 @@ print as builtin_print
*args: object
sep: object(c_default="Py_None") = ' '
end: object(c_default="NULL") = '\n'
string inserted between values, default a space.
end: object(c_default="Py_None") = '\n'
string appended after the last value, default a newline.
file: object = None
a file-like object (stream); defaults to the current sys.stdout.
flush: bool = False
whether to forcibly flush the stream.
Prints the values to a stream, or to sys.stdout by default.
Optional keyword arguments:
file: a file-like object (stream); defaults to the current sys.stdout.
sep: string inserted between values, default a space.
end: string appended after the last value, default a newline.
flush: whether to forcibly flush the stream.
[clinic start generated code]*/
static PyObject *
builtin_print_impl(PyObject *module, PyObject *args, PyObject *sep,
PyObject *end, PyObject *file, int flush)
/*[clinic end generated code: output=3cfc0940f5bc237b input=fc06c31f642dd77b]*/
/*[clinic end generated code: output=3cfc0940f5bc237b input=c143c575d24fe665]*/
{
int i, err;
if (file == NULL || file == Py_None) {
if (file == Py_None) {
file = _PySys_GetObjectId(&PyId_stdout);
if (file == NULL) {
PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");

View File

@ -628,16 +628,19 @@ exit:
}
PyDoc_STRVAR(builtin_print__doc__,
"print($module, /, *args, sep=\' \', end=\'\\\\n\', file=None, flush=False)\n"
"print($module, /, *args, sep=\' \', end=\'\\n\', file=None, flush=False)\n"
"--\n"
"\n"
"Prints the values to a stream, or to sys.stdout by default.\n"
"\n"
"Optional keyword arguments:\n"
"file: a file-like object (stream); defaults to the current sys.stdout.\n"
"sep: string inserted between values, default a space.\n"
"end: string appended after the last value, default a newline.\n"
"flush: whether to forcibly flush the stream.");
" sep\n"
" string inserted between values, default a space.\n"
" end\n"
" string appended after the last value, default a newline.\n"
" file\n"
" a file-like object (stream); defaults to the current sys.stdout.\n"
" flush\n"
" whether to forcibly flush the stream.");
#define BUILTIN_PRINT_METHODDEF \
{"print", (PyCFunction)(void(*)(void))builtin_print, METH_FASTCALL|METH_KEYWORDS, builtin_print__doc__},
@ -655,9 +658,9 @@ builtin_print(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObjec
PyObject *argsbuf[5];
Py_ssize_t noptargs = 0 + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
PyObject *__clinic_args = NULL;
PyObject *sep = NULL;
PyObject *end = NULL;
PyObject *file = NULL;
PyObject *sep = Py_None;
PyObject *end = Py_None;
PyObject *file = Py_None;
int flush = 0;
args = _PyArg_UnpackKeywordsWithVararg(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, 0, argsbuf);
@ -901,4 +904,4 @@ builtin_issubclass(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
exit:
return return_value;
}
/*[clinic end generated code: output=0931a7e1da399775 input=a9049054013a1b77]*/
/*[clinic end generated code: output=78f2bb2617127934 input=a9049054013a1b77]*/