Skip to content

Commit 3a8c1ca

Browse files
gh-117764: Fix and add signatures for many builtins (GH-117769)
1 parent 94e9c35 commit 3a8c1ca

11 files changed

+45
-30
lines changed

Objects/clinic/descrobject.c.h

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Objects/descrobject.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,8 +1165,8 @@ mappingproxy_reversed(PyObject *self, PyObject *Py_UNUSED(ignored))
11651165

11661166
static PyMethodDef mappingproxy_methods[] = {
11671167
{"get", _PyCFunction_CAST(mappingproxy_get), METH_FASTCALL,
1168-
PyDoc_STR("D.get(k[,d]) -> D[k] if k in D, else d."
1169-
" d defaults to None.")},
1168+
PyDoc_STR("get($self, key, default=None, /)\n--\n\n"
1169+
"Return the value for key if key is in the mapping, else default.")},
11701170
{"keys", mappingproxy_keys, METH_NOARGS,
11711171
PyDoc_STR("D.keys() -> a set-like object providing a view on D's keys")},
11721172
{"values", mappingproxy_values, METH_NOARGS,
@@ -1254,11 +1254,12 @@ mappingproxy.__new__ as mappingproxy_new
12541254
12551255
mapping: object
12561256
1257+
Read-only proxy of a mapping.
12571258
[clinic start generated code]*/
12581259

12591260
static PyObject *
12601261
mappingproxy_new_impl(PyTypeObject *type, PyObject *mapping)
1261-
/*[clinic end generated code: output=65f27f02d5b68fa7 input=d2d620d4f598d4f8]*/
1262+
/*[clinic end generated code: output=65f27f02d5b68fa7 input=c156df096ef7590c]*/
12621263
{
12631264
mappingproxyobject *mappingproxy;
12641265

@@ -2024,7 +2025,7 @@ PyTypeObject PyDictProxy_Type = {
20242025
0, /* tp_as_buffer */
20252026
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
20262027
Py_TPFLAGS_MAPPING, /* tp_flags */
2027-
0, /* tp_doc */
2028+
mappingproxy_new__doc__, /* tp_doc */
20282029
mappingproxy_traverse, /* tp_traverse */
20292030
0, /* tp_clear */
20302031
mappingproxy_richcompare, /* tp_richcompare */

Objects/genericaliasobject.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,8 @@ _Py_subs_parameters(PyObject *self, PyObject *args, PyObject *parameters, PyObje
537537
}
538538

539539
PyDoc_STRVAR(genericalias__doc__,
540+
"GenericAlias(origin, args, /)\n"
541+
"--\n\n"
540542
"Represent a PEP 585 generic type\n"
541543
"\n"
542544
"E.g. for t = list[int], t.__origin__ is list and t.__args__ is (int,).");

Objects/memoryobject.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3255,6 +3255,9 @@ PyDoc_STRVAR(memory_f_contiguous_doc,
32553255
"A bool indicating whether the memory is Fortran contiguous.");
32563256
PyDoc_STRVAR(memory_contiguous_doc,
32573257
"A bool indicating whether the memory is contiguous.");
3258+
PyDoc_STRVAR(memory_exit_doc,
3259+
"__exit__($self, /, *exc_info)\n--\n\n"
3260+
"Release the underlying buffer exposed by the memoryview object.");
32583261

32593262

32603263
static PyGetSetDef memory_getsetlist[] = {
@@ -3283,7 +3286,7 @@ static PyMethodDef memory_methods[] = {
32833286
MEMORYVIEW_TOREADONLY_METHODDEF
32843287
MEMORYVIEW__FROM_FLAGS_METHODDEF
32853288
{"__enter__", memory_enter, METH_NOARGS, NULL},
3286-
{"__exit__", memory_exit, METH_VARARGS, NULL},
3289+
{"__exit__", memory_exit, METH_VARARGS, memory_exit_doc},
32873290
{NULL, NULL}
32883291
};
32893292

Objects/namespaceobject.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@ static PyMethodDef namespace_methods[] = {
227227

228228

229229
PyDoc_STRVAR(namespace_doc,
230-
"A simple attribute-based namespace.\n\
231-
\n\
232-
SimpleNamespace(**kwargs)");
230+
"SimpleNamespace(**kwargs)\n\
231+
--\n\n\
232+
A simple attribute-based namespace.");
233233

234234
PyTypeObject _PyNamespace_Type = {
235235
PyVarObject_HEAD_INIT(&PyType_Type, 0)

Objects/rangeobject.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ PyDoc_STRVAR(index_doc,
751751

752752
static PyMethodDef range_methods[] = {
753753
{"__reversed__", range_reverse, METH_NOARGS, reverse_doc},
754-
{"__reduce__", (PyCFunction)range_reduce, METH_VARARGS},
754+
{"__reduce__", (PyCFunction)range_reduce, METH_NOARGS},
755755
{"count", (PyCFunction)range_count, METH_O, count_doc},
756756
{"index", (PyCFunction)range_index, METH_O, index_doc},
757757
{NULL, NULL} /* sentinel */

Objects/typeobject.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6917,7 +6917,7 @@ static PyMethodDef object_methods[] = {
69176917
OBJECT___REDUCE_EX___METHODDEF
69186918
OBJECT___REDUCE___METHODDEF
69196919
OBJECT___GETSTATE___METHODDEF
6920-
{"__subclasshook__", object_subclasshook, METH_CLASS | METH_VARARGS,
6920+
{"__subclasshook__", object_subclasshook, METH_CLASS | METH_O,
69216921
object_subclasshook_doc},
69226922
{"__init_subclass__", object_init_subclass, METH_CLASS | METH_NOARGS,
69236923
object_init_subclass_doc},
@@ -9893,7 +9893,8 @@ static pytype_slotdef slotdefs[] = {
98939893
TPSLOT(__getattribute__, tp_getattro, _Py_slot_tp_getattr_hook,
98949894
wrap_binaryfunc,
98959895
"__getattribute__($self, name, /)\n--\n\nReturn getattr(self, name)."),
9896-
TPSLOT(__getattr__, tp_getattro, _Py_slot_tp_getattr_hook, NULL, ""),
9896+
TPSLOT(__getattr__, tp_getattro, _Py_slot_tp_getattr_hook, NULL,
9897+
"__getattr__($self, name, /)\n--\n\nImplement getattr(self, name)."),
98979898
TPSLOT(__setattr__, tp_setattro, slot_tp_setattro, wrap_setattr,
98989899
"__setattr__($self, name, value, /)\n--\n\nImplement setattr(self, name, value)."),
98999900
TPSLOT(__delattr__, tp_setattro, slot_tp_setattro, wrap_delattr,
@@ -9928,7 +9929,9 @@ static pytype_slotdef slotdefs[] = {
99289929
TPSLOT(__new__, tp_new, slot_tp_new, NULL,
99299930
"__new__(type, /, *args, **kwargs)\n--\n\n"
99309931
"Create and return new object. See help(type) for accurate signature."),
9931-
TPSLOT(__del__, tp_finalize, slot_tp_finalize, (wrapperfunc)wrap_del, ""),
9932+
TPSLOT(__del__, tp_finalize, slot_tp_finalize, (wrapperfunc)wrap_del,
9933+
"__del__($self, /)\n--\n\n"
9934+
"Called when the instance is about to be destroyed."),
99329935

99339936
BUFSLOT(__buffer__, bf_getbuffer, slot_bf_getbuffer, wrap_buffer,
99349937
"__buffer__($self, flags, /)\n--\n\n"

Python/bltinmodule.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ builtin_breakpoint(PyObject *self, PyObject *const *args, Py_ssize_t nargs, PyOb
475475
}
476476

477477
PyDoc_STRVAR(breakpoint_doc,
478-
"breakpoint(*args, **kws)\n\
478+
"breakpoint($module, /, *args, **kws)\n\
479479
--\n\
480480
\n\
481481
Call sys.breakpointhook(*args, **kws). sys.breakpointhook() must accept\n\
@@ -1703,16 +1703,16 @@ anext as builtin_anext
17031703
default: object = NULL
17041704
/
17051705
1706-
async anext(aiterator[, default])
1706+
Return the next item from the async iterator.
17071707
1708-
Return the next item from the async iterator. If default is given and the async
1709-
iterator is exhausted, it is returned instead of raising StopAsyncIteration.
1708+
If default is given and the async iterator is exhausted,
1709+
it is returned instead of raising StopAsyncIteration.
17101710
[clinic start generated code]*/
17111711

17121712
static PyObject *
17131713
builtin_anext_impl(PyObject *module, PyObject *aiterator,
17141714
PyObject *default_value)
1715-
/*[clinic end generated code: output=f02c060c163a81fa input=8f63f4f78590bb4c]*/
1715+
/*[clinic end generated code: output=f02c060c163a81fa input=2900e4a370d39550]*/
17161716
{
17171717
PyTypeObject *t;
17181718
PyObject *awaitable;

Python/clinic/bltinmodule.c.h

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/clinic/traceback.c.h

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/traceback.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
extern char* _PyTokenizer_FindEncodingFilename(int, PyObject *);
3535

3636
/*[clinic input]
37-
class TracebackType "PyTracebackObject *" "&PyTraceback_Type"
37+
class traceback "PyTracebackObject *" "&PyTraceback_Type"
3838
[clinic start generated code]*/
39-
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=928fa06c10151120]*/
39+
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=cf96294b2bebc811]*/
4040

4141
#include "clinic/traceback.c.h"
4242

@@ -63,7 +63,7 @@ tb_create_raw(PyTracebackObject *next, PyFrameObject *frame, int lasti,
6363

6464
/*[clinic input]
6565
@classmethod
66-
TracebackType.__new__ as tb_new
66+
traceback.__new__ as tb_new
6767
6868
tb_next: object
6969
tb_frame: object(type='PyFrameObject *', subclass_of='&PyFrame_Type')
@@ -76,7 +76,7 @@ Create a new traceback object.
7676
static PyObject *
7777
tb_new_impl(PyTypeObject *type, PyObject *tb_next, PyFrameObject *tb_frame,
7878
int tb_lasti, int tb_lineno)
79-
/*[clinic end generated code: output=fa077debd72d861a input=01cbe8ec8783fca7]*/
79+
/*[clinic end generated code: output=fa077debd72d861a input=b88143145454cb59]*/
8080
{
8181
if (tb_next == Py_None) {
8282
tb_next = NULL;

0 commit comments

Comments
 (0)