gh-150285: Fix too long docstrings in Argument Clinic code (GH-150338)

This commit is contained in:
Serhiy Storchaka 2026-05-24 16:16:12 +03:00 committed by GitHub
parent 0563890872
commit 287c98f4cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
91 changed files with 768 additions and 702 deletions

View file

@ -10,8 +10,8 @@ PyDoc_STRVAR(_contextvars_Context_get__doc__,
"\n"
"Return the value for `key` if `key` has the value in the context object.\n"
"\n"
"If `key` does not exist, return `default`. If `default` is not given,\n"
"return None.");
"If `key` does not exist, return `default`. If `default` is not\n"
"given, return None.");
#define _CONTEXTVARS_CONTEXT_GET_METHODDEF \
{"get", _PyCFunction_CAST(_contextvars_Context_get), METH_FASTCALL, _contextvars_Context_get__doc__},
@ -122,10 +122,12 @@ PyDoc_STRVAR(_contextvars_ContextVar_get__doc__,
"\n"
"Return a value for the context variable for the current context.\n"
"\n"
"If there is no value for the variable in the current context, the method will:\n"
" * return the value of the default argument of the method, if provided; or\n"
" * return the default value for the context variable, if it was created\n"
" with one; or\n"
"If there is no value for the variable in the current context, the\n"
"method will:\n"
" * return the value of the default argument of the method, if\n"
" provided; or\n"
" * return the default value for the context variable, if it was\n"
" created with one; or\n"
" * raise a LookupError.");
#define _CONTEXTVARS_CONTEXTVAR_GET_METHODDEF \
@ -160,10 +162,11 @@ PyDoc_STRVAR(_contextvars_ContextVar_set__doc__,
"\n"
"Call to set a new value for the context variable in the current context.\n"
"\n"
"The required value argument is the new value for the context variable.\n"
"The required value argument is the new value for the context\n"
"variable.\n"
"\n"
"Returns a Token object that can be used to restore the variable to its previous\n"
"value via the `ContextVar.reset()` method.");
"Returns a Token object that can be used to restore the variable to\n"
"its previous value via the `ContextVar.reset()` method.");
#define _CONTEXTVARS_CONTEXTVAR_SET_METHODDEF \
{"set", (PyCFunction)_contextvars_ContextVar_set, METH_O, _contextvars_ContextVar_set__doc__},
@ -187,8 +190,8 @@ PyDoc_STRVAR(_contextvars_ContextVar_reset__doc__,
"\n"
"Reset the context variable.\n"
"\n"
"The variable is reset to the value it had before the `ContextVar.set()` that\n"
"created the token was used.");
"The variable is reset to the value it had before the\n"
"`ContextVar.set()` that created the token was used.");
#define _CONTEXTVARS_CONTEXTVAR_RESET_METHODDEF \
{"reset", (PyCFunction)_contextvars_ContextVar_reset, METH_O, _contextvars_ContextVar_reset__doc__},
@ -256,4 +259,4 @@ token_exit(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
exit:
return return_value;
}
/*[clinic end generated code: output=3a04b2fddf24c3e9 input=a9049054013a1b77]*/
/*[clinic end generated code: output=90ec3e4375804e9b input=a9049054013a1b77]*/

View file

@ -34,8 +34,9 @@ PyDoc_STRVAR(_imp_acquire_lock__doc__,
"\n"
"Acquires the interpreter\'s import lock for the current thread.\n"
"\n"
"This lock should be used by import hooks to ensure thread-safety when importing\n"
"modules. On platforms without threads, this function does nothing.");
"This lock should be used by import hooks to ensure thread-safety when\n"
"importing modules. On platforms without threads, this function does\n"
"nothing.");
#define _IMP_ACQUIRE_LOCK_METHODDEF \
{"acquire_lock", (PyCFunction)_imp_acquire_lock, METH_NOARGS, _imp_acquire_lock__doc__},
@ -664,4 +665,4 @@ exit:
#ifndef _IMP_EXEC_DYNAMIC_METHODDEF
#define _IMP_EXEC_DYNAMIC_METHODDEF
#endif /* !defined(_IMP_EXEC_DYNAMIC_METHODDEF) */
/*[clinic end generated code: output=5fa42f580441b3fa input=a9049054013a1b77]*/
/*[clinic end generated code: output=0974db098d601372 input=a9049054013a1b77]*/

View file

@ -195,8 +195,8 @@ PyDoc_STRVAR(marshal_dumps__doc__,
" allow_code\n"
" Allow to write code objects.\n"
"\n"
"Raise a ValueError exception if value has (or contains an object that has) an\n"
"unsupported type.");
"Raise a ValueError exception if value has (or contains an object that\n"
"has) an unsupported type.");
#define MARSHAL_DUMPS_METHODDEF \
{"dumps", _PyCFunction_CAST(marshal_dumps), METH_FASTCALL|METH_KEYWORDS, marshal_dumps__doc__},
@ -280,8 +280,8 @@ PyDoc_STRVAR(marshal_loads__doc__,
" allow_code\n"
" Allow to load code objects.\n"
"\n"
"If no valid value is found, raise EOFError, ValueError or TypeError. Extra\n"
"bytes in the input are ignored.");
"If no valid value is found, raise EOFError, ValueError or TypeError.\n"
"Extra bytes in the input are ignored.");
#define MARSHAL_LOADS_METHODDEF \
{"loads", _PyCFunction_CAST(marshal_loads), METH_FASTCALL|METH_KEYWORDS, marshal_loads__doc__},
@ -351,4 +351,4 @@ exit:
return return_value;
}
/*[clinic end generated code: output=3e4bfc070a3c78ac input=a9049054013a1b77]*/
/*[clinic end generated code: output=a574570c3717f60e input=a9049054013a1b77]*/

View file

@ -1367,7 +1367,8 @@ PyDoc_STRVAR(sys__stats_dump__doc__,
"\n"
"Dump stats to file, and clears the stats.\n"
"\n"
"Return False if no statistics were not dumped because stats gathering was off.");
"Return False if no statistics were not dumped because stats gathering\n"
"was off.");
#define SYS__STATS_DUMP_METHODDEF \
{"_stats_dump", (PyCFunction)sys__stats_dump, METH_NOARGS, sys__stats_dump__doc__},
@ -1515,16 +1516,16 @@ PyDoc_STRVAR(sys_remote_exec__doc__,
"Executes a file containing Python code in a given remote Python process.\n"
"\n"
"This function returns immediately, and the code will be executed by the\n"
"target process\'s main thread at the next available opportunity, similarly\n"
"to how signals are handled. There is no interface to determine when the\n"
"code has been executed. The caller is responsible for making sure that\n"
"the file still exists whenever the remote process tries to read it and that\n"
"it hasn\'t been overwritten.\n"
"target process\'s main thread at the next available opportunity,\n"
"similarly to how signals are handled. There is no interface to\n"
"determine when the code has been executed. The caller is responsible\n"
"for making sure that the file still exists whenever the remote process\n"
"tries to read it and that it hasn\'t been overwritten.\n"
"\n"
"The remote process must be running a CPython interpreter of the same major\n"
"and minor version as the local process. If either the local or remote\n"
"interpreter is pre-release (alpha, beta, or release candidate) then the\n"
"local and remote interpreters must be the same exact version.\n"
"The remote process must be running a CPython interpreter of the same\n"
"major and minor version as the local process. If either the local or\n"
"remote interpreter is pre-release (alpha, beta, or release candidate)\n"
"then the local and remote interpreters must be the same exact version.\n"
"\n"
"Args:\n"
" pid (int): The process ID of the target Python process.\n"
@ -1886,7 +1887,8 @@ PyDoc_STRVAR(sys_set_lazy_imports__doc__,
"\n"
"The mode parameter must be one of the following strings:\n"
"- \"all\": All top-level imports become potentially lazy\n"
"- \"normal\": Only explicitly marked imports (with \'lazy\' keyword) are lazy\n"
"- \"normal\": Only explicitly marked imports (with \'lazy\' keyword) are\n"
" lazy\n"
"\n"
"In addition to the mode, lazy imports can be controlled via the filter\n"
"provided to sys.set_lazy_imports_filter");
@ -2087,4 +2089,4 @@ exit:
#ifndef SYS_GETANDROIDAPILEVEL_METHODDEF
#define SYS_GETANDROIDAPILEVEL_METHODDEF
#endif /* !defined(SYS_GETANDROIDAPILEVEL_METHODDEF) */
/*[clinic end generated code: output=fb4fe1af274124e0 input=a9049054013a1b77]*/
/*[clinic end generated code: output=8a4482f9c5c493e5 input=a9049054013a1b77]*/

View file

@ -618,6 +618,7 @@ context_tp_contains(PyObject *op, PyObject *key)
/*[clinic input]
@permit_long_summary
_contextvars.Context.get
key: object
default: object = None
@ -625,14 +626,14 @@ _contextvars.Context.get
Return the value for `key` if `key` has the value in the context object.
If `key` does not exist, return `default`. If `default` is not given,
return None.
If `key` does not exist, return `default`. If `default` is not
given, return None.
[clinic start generated code]*/
static PyObject *
_contextvars_Context_get_impl(PyContext *self, PyObject *key,
PyObject *default_value)
/*[clinic end generated code: output=0c54aa7664268189 input=c8eeb81505023995]*/
/*[clinic end generated code: output=0c54aa7664268189 input=d669a0d56fabb0a5]*/
{
if (context_check_key_type(key)) {
return NULL;
@ -1006,23 +1007,24 @@ contextvar_tp_repr(PyObject *op)
/*[clinic input]
@permit_long_docstring_body
_contextvars.ContextVar.get
default: object = NULL
/
Return a value for the context variable for the current context.
If there is no value for the variable in the current context, the method will:
* return the value of the default argument of the method, if provided; or
* return the default value for the context variable, if it was created
with one; or
If there is no value for the variable in the current context, the
method will:
* return the value of the default argument of the method, if
provided; or
* return the default value for the context variable, if it was
created with one; or
* raise a LookupError.
[clinic start generated code]*/
static PyObject *
_contextvars_ContextVar_get_impl(PyContextVar *self, PyObject *default_value)
/*[clinic end generated code: output=0746bd0aa2ced7bf input=da66664d5d0af4ad]*/
/*[clinic end generated code: output=0746bd0aa2ced7bf input=83814c6aef4a9fe3]*/
{
PyObject *val;
if (PyContextVar_Get((PyObject *)self, default_value, &val) < 0) {
@ -1038,41 +1040,41 @@ _contextvars_ContextVar_get_impl(PyContextVar *self, PyObject *default_value)
}
/*[clinic input]
@permit_long_docstring_body
@permit_long_summary
_contextvars.ContextVar.set
value: object
/
Call to set a new value for the context variable in the current context.
The required value argument is the new value for the context variable.
The required value argument is the new value for the context
variable.
Returns a Token object that can be used to restore the variable to its previous
value via the `ContextVar.reset()` method.
Returns a Token object that can be used to restore the variable to
its previous value via the `ContextVar.reset()` method.
[clinic start generated code]*/
static PyObject *
_contextvars_ContextVar_set_impl(PyContextVar *self, PyObject *value)
/*[clinic end generated code: output=1b562d35cc79c806 input=73ebbbfc7c98f6cd]*/
/*[clinic end generated code: output=1b562d35cc79c806 input=04ef8dcd810f5be6]*/
{
return PyContextVar_Set((PyObject *)self, value);
}
/*[clinic input]
@permit_long_docstring_body
_contextvars.ContextVar.reset
token: object
/
Reset the context variable.
The variable is reset to the value it had before the `ContextVar.set()` that
created the token was used.
The variable is reset to the value it had before the
`ContextVar.set()` that created the token was used.
[clinic start generated code]*/
static PyObject *
_contextvars_ContextVar_reset_impl(PyContextVar *self, PyObject *token)
/*[clinic end generated code: output=3205d2bdff568521 input=b8bc514a9245242a]*/
/*[clinic end generated code: output=3205d2bdff568521 input=dd33cfcb18c00e37]*/
{
if (!PyContextToken_CheckExact(token)) {
PyErr_Format(PyExc_TypeError,

View file

@ -5003,18 +5003,18 @@ _imp_lock_held_impl(PyObject *module)
}
/*[clinic input]
@permit_long_docstring_body
_imp.acquire_lock
Acquires the interpreter's import lock for the current thread.
This lock should be used by import hooks to ensure thread-safety when importing
modules. On platforms without threads, this function does nothing.
This lock should be used by import hooks to ensure thread-safety when
importing modules. On platforms without threads, this function does
nothing.
[clinic start generated code]*/
static PyObject *
_imp_acquire_lock_impl(PyObject *module)
/*[clinic end generated code: output=1aff58cb0ee1b026 input=e1a4ef049d34e7dd]*/
/*[clinic end generated code: output=1aff58cb0ee1b026 input=60e9c1b4ab471ead]*/
{
PyInterpreterState *interp = _PyInterpreterState_GET();
_PyImport_AcquireLock(interp);
@ -5172,6 +5172,7 @@ _imp_init_frozen_impl(PyObject *module, PyObject *name)
}
/*[clinic input]
@permit_long_summary
_imp.find_frozen
name: unicode
@ -5192,7 +5193,7 @@ The returned info (a 2-tuple):
static PyObject *
_imp_find_frozen_impl(PyObject *module, PyObject *name, int withdata)
/*[clinic end generated code: output=8c1c3c7f925397a5 input=22a8847c201542fd]*/
/*[clinic end generated code: output=8c1c3c7f925397a5 input=30a7a50da49eca97]*/
{
struct frozen_info info;
frozen_status status = find_frozen(name, &info);
@ -5379,6 +5380,7 @@ _imp__override_frozen_modules_for_tests_impl(PyObject *module, int override)
}
/*[clinic input]
@permit_long_summary
_imp._override_multi_interp_extensions_check
override: int
@ -5392,7 +5394,7 @@ _imp._override_multi_interp_extensions_check
static PyObject *
_imp__override_multi_interp_extensions_check_impl(PyObject *module,
int override)
/*[clinic end generated code: output=3ff043af52bbf280 input=e086a2ea181f92ae]*/
/*[clinic end generated code: output=3ff043af52bbf280 input=24f23f8510a7f6e7]*/
{
PyInterpreterState *interp = _PyInterpreterState_GET();
if (_Py_IsMainInterpreter(interp)) {

View file

@ -2061,7 +2061,6 @@ marshal_load_impl(PyObject *module, PyObject *file, int allow_code)
/*[clinic input]
@permit_long_summary
@permit_long_docstring_body
marshal.dumps
value: object
@ -2075,14 +2074,14 @@ marshal.dumps
Return the bytes object that would be written to a file by dump(value, file).
Raise a ValueError exception if value has (or contains an object that has) an
unsupported type.
Raise a ValueError exception if value has (or contains an object that
has) an unsupported type.
[clinic start generated code]*/
static PyObject *
marshal_dumps_impl(PyObject *module, PyObject *value, int version,
int allow_code)
/*[clinic end generated code: output=115f90da518d1d49 input=80cd3f30c1637ade]*/
/*[clinic end generated code: output=115f90da518d1d49 input=dc1edcafd43124c5]*/
{
return _PyMarshal_WriteObjectToString(value, version, allow_code);
}
@ -2098,13 +2097,13 @@ marshal.loads
Convert the bytes-like object to a value.
If no valid value is found, raise EOFError, ValueError or TypeError. Extra
bytes in the input are ignored.
If no valid value is found, raise EOFError, ValueError or TypeError.
Extra bytes in the input are ignored.
[clinic start generated code]*/
static PyObject *
marshal_loads_impl(PyObject *module, Py_buffer *bytes, int allow_code)
/*[clinic end generated code: output=62c0c538d3edc31f input=14de68965b45aaa7]*/
/*[clinic end generated code: output=62c0c538d3edc31f input=286f1dbd6811d2ad]*/
{
RFILE rf;
char *s = bytes->buf;

View file

@ -1863,6 +1863,7 @@ sys_mdebug_impl(PyObject *module, int flag)
/*[clinic input]
@permit_long_summary
sys.get_int_max_str_digits
Return the maximum string digits limit for non-binary int<->str conversions.
@ -1870,7 +1871,7 @@ Return the maximum string digits limit for non-binary int<->str conversions.
static PyObject *
sys_get_int_max_str_digits_impl(PyObject *module)
/*[clinic end generated code: output=0042f5e8ae0e8631 input=61bf9f99bc8b112d]*/
/*[clinic end generated code: output=0042f5e8ae0e8631 input=77fb74e987ba7ecb]*/
{
PyInterpreterState *interp = _PyInterpreterState_GET();
return PyLong_FromLong(interp->long_state.max_str_digits);
@ -1878,6 +1879,7 @@ sys_get_int_max_str_digits_impl(PyObject *module)
/*[clinic input]
@permit_long_summary
sys.set_int_max_str_digits
maxdigits: int
@ -1887,7 +1889,7 @@ Set the maximum string digits limit for non-binary int<->str conversions.
static PyObject *
sys_set_int_max_str_digits_impl(PyObject *module, int maxdigits)
/*[clinic end generated code: output=734d4c2511f2a56d input=d7e3f325db6910c5]*/
/*[clinic end generated code: output=734d4c2511f2a56d input=d4c0bf50c466d57a]*/
{
if (_PySys_SetIntMaxStrDigits(maxdigits) < 0) {
return NULL;
@ -2099,6 +2101,7 @@ sys__getframe_impl(PyObject *module, int depth)
}
/*[clinic input]
@permit_long_summary
sys._current_frames
Return a dict mapping each thread's thread id to its current stack frame.
@ -2108,7 +2111,7 @@ This function should be used for specialized purposes only.
static PyObject *
sys__current_frames_impl(PyObject *module)
/*[clinic end generated code: output=d2a41ac0a0a3809a input=2a9049c5f5033691]*/
/*[clinic end generated code: output=d2a41ac0a0a3809a input=e1ce34f43501e0d6]*/
{
return _PyThread_CurrentFrames();
}
@ -2287,17 +2290,17 @@ sys__stats_clear_impl(PyObject *module)
}
/*[clinic input]
@permit_long_docstring_body
sys._stats_dump -> bool
Dump stats to file, and clears the stats.
Return False if no statistics were not dumped because stats gathering was off.
Return False if no statistics were not dumped because stats gathering
was off.
[clinic start generated code]*/
static int
sys__stats_dump_impl(PyObject *module)
/*[clinic end generated code: output=6e346b4ba0de4489 input=5a3ab40d2fb5af47]*/
/*[clinic end generated code: output=6e346b4ba0de4489 input=7f3b7758cb59d2ff]*/
{
int res = _Py_PrintSpecializationStats(1);
_Py_StatsClear();
@ -2441,16 +2444,16 @@ sys.remote_exec
Executes a file containing Python code in a given remote Python process.
This function returns immediately, and the code will be executed by the
target process's main thread at the next available opportunity, similarly
to how signals are handled. There is no interface to determine when the
code has been executed. The caller is responsible for making sure that
the file still exists whenever the remote process tries to read it and that
it hasn't been overwritten.
target process's main thread at the next available opportunity,
similarly to how signals are handled. There is no interface to
determine when the code has been executed. The caller is responsible
for making sure that the file still exists whenever the remote process
tries to read it and that it hasn't been overwritten.
The remote process must be running a CPython interpreter of the same major
and minor version as the local process. If either the local or remote
interpreter is pre-release (alpha, beta, or release candidate) then the
local and remote interpreters must be the same exact version.
The remote process must be running a CPython interpreter of the same
major and minor version as the local process. If either the local or
remote interpreter is pre-release (alpha, beta, or release candidate)
then the local and remote interpreters must be the same exact version.
Args:
pid (int): The process ID of the target Python process.
@ -2460,7 +2463,7 @@ local and remote interpreters must be the same exact version.
static PyObject *
sys_remote_exec_impl(PyObject *module, int pid, PyObject *script)
/*[clinic end generated code: output=7d94c56afe4a52c0 input=39908ca2c5fe1eb0]*/
/*[clinic end generated code: output=7d94c56afe4a52c0 input=7bd58f8da20cb74c]*/
{
PyObject *path;
const char *debugger_script_path;
@ -2812,7 +2815,8 @@ Sets the global lazy imports mode.
The mode parameter must be one of the following strings:
- "all": All top-level imports become potentially lazy
- "normal": Only explicitly marked imports (with 'lazy' keyword) are lazy
- "normal": Only explicitly marked imports (with 'lazy' keyword) are
lazy
In addition to the mode, lazy imports can be controlled via the filter
provided to sys.set_lazy_imports_filter
@ -2821,7 +2825,7 @@ provided to sys.set_lazy_imports_filter
static PyObject *
sys_set_lazy_imports_impl(PyObject *module, PyObject *mode)
/*[clinic end generated code: output=1ff34ba6c4feaf73 input=036c75a65f42cbc2]*/
/*[clinic end generated code: output=1ff34ba6c4feaf73 input=db3242f0ff6e5dcc]*/
{
PyImport_LazyImportsMode lazy_mode;
if (!PyUnicode_Check(mode)) {