Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 69a2547

Browse files
committed
Issue #20530: The signatures for slot builtins have been updated
to reflect the fact that they only accept positional-only arguments.
1 parent b082731 commit 69a2547

2 files changed

Lines changed: 45 additions & 42 deletions

File tree

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ Core and Builtins
3232
Library
3333
-------
3434

35+
- Issue #20530: The signatures for slot builtins have been updated
36+
to reflect the fact that they only accept positional-only arguments.
37+
3538
- Issue #20517: Functions in the os module that accept two filenames
3639
now register both filenames in the exception on failure.
3740

Objects/typeobject.c

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6134,74 +6134,74 @@ typedef struct wrapperbase slotdef;
61346134
ETSLOT(NAME, as_number.SLOT, FUNCTION, WRAPPER, DOC)
61356135
#define UNSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \
61366136
ETSLOT(NAME, as_number.SLOT, FUNCTION, WRAPPER, \
6137-
NAME "($self)\n--\n\n" DOC)
6137+
NAME "($self, /)\n--\n\n" DOC)
61386138
#define IBSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \
61396139
ETSLOT(NAME, as_number.SLOT, FUNCTION, WRAPPER, \
6140-
NAME "($self, value)\n--\n\nReturn self" DOC "value.")
6140+
NAME "($self, value, /)\n--\n\nReturn self" DOC "value.")
61416141
#define BINSLOT(NAME, SLOT, FUNCTION, DOC) \
61426142
ETSLOT(NAME, as_number.SLOT, FUNCTION, wrap_binaryfunc_l, \
6143-
NAME "($self, value)\n--\n\nReturn self" DOC "value.")
6143+
NAME "($self, value, /)\n--\n\nReturn self" DOC "value.")
61446144
#define RBINSLOT(NAME, SLOT, FUNCTION, DOC) \
61456145
ETSLOT(NAME, as_number.SLOT, FUNCTION, wrap_binaryfunc_r, \
6146-
NAME "($self, value)\n--\n\nReturn value" DOC "self.")
6146+
NAME "($self, value, /)\n--\n\nReturn value" DOC "self.")
61476147
#define BINSLOTNOTINFIX(NAME, SLOT, FUNCTION, DOC) \
61486148
ETSLOT(NAME, as_number.SLOT, FUNCTION, wrap_binaryfunc_l, \
6149-
NAME "($self, value)\n--\n\n" DOC)
6149+
NAME "($self, value, /)\n--\n\n" DOC)
61506150
#define RBINSLOTNOTINFIX(NAME, SLOT, FUNCTION, DOC) \
61516151
ETSLOT(NAME, as_number.SLOT, FUNCTION, wrap_binaryfunc_r, \
6152-
NAME "($self, value)\n--\n\n" DOC)
6152+
NAME "($self, value, /)\n--\n\n" DOC)
61536153

61546154
static slotdef slotdefs[] = {
61556155
TPSLOT("__getattribute__", tp_getattr, NULL, NULL, ""),
61566156
TPSLOT("__getattr__", tp_getattr, NULL, NULL, ""),
61576157
TPSLOT("__setattr__", tp_setattr, NULL, NULL, ""),
61586158
TPSLOT("__delattr__", tp_setattr, NULL, NULL, ""),
61596159
TPSLOT("__repr__", tp_repr, slot_tp_repr, wrap_unaryfunc,
6160-
"__repr__($self)\n--\n\nReturn repr(self)."),
6160+
"__repr__($self, /)\n--\n\nReturn repr(self)."),
61616161
TPSLOT("__hash__", tp_hash, slot_tp_hash, wrap_hashfunc,
6162-
"__hash__($self)\n--\n\nReturn hash(self)."),
6162+
"__hash__($self, /)\n--\n\nReturn hash(self)."),
61636163
FLSLOT("__call__", tp_call, slot_tp_call, (wrapperfunc)wrap_call,
6164-
"__call__($self, *args, **kwargs)\n--\n\nCall self as a function.",
6164+
"__call__($self, /, *args, **kwargs)\n--\n\nCall self as a function.",
61656165
PyWrapperFlag_KEYWORDS),
61666166
TPSLOT("__str__", tp_str, slot_tp_str, wrap_unaryfunc,
6167-
"__str__($self)\n--\n\nReturn str(self)."),
6167+
"__str__($self, /)\n--\n\nReturn str(self)."),
61686168
TPSLOT("__getattribute__", tp_getattro, slot_tp_getattr_hook,
61696169
wrap_binaryfunc,
6170-
"__getattribute__($self, name)\n--\n\nReturn getattr(self, name)."),
6170+
"__getattribute__($self, name, /)\n--\n\nReturn getattr(self, name)."),
61716171
TPSLOT("__getattr__", tp_getattro, slot_tp_getattr_hook, NULL, ""),
61726172
TPSLOT("__setattr__", tp_setattro, slot_tp_setattro, wrap_setattr,
6173-
"__setattr__($self, name, value)\n--\n\nImplement setattr(self, name, value)."),
6173+
"__setattr__($self, name, value, /)\n--\n\nImplement setattr(self, name, value)."),
61746174
TPSLOT("__delattr__", tp_setattro, slot_tp_setattro, wrap_delattr,
6175-
"__delattr__($self, name)\n--\n\nImplement delattr(self, name)."),
6175+
"__delattr__($self, name, /)\n--\n\nImplement delattr(self, name)."),
61766176
TPSLOT("__lt__", tp_richcompare, slot_tp_richcompare, richcmp_lt,
6177-
"__lt__($self, value)\n--\n\nReturn self<value."),
6177+
"__lt__($self, value, /)\n--\n\nReturn self<value."),
61786178
TPSLOT("__le__", tp_richcompare, slot_tp_richcompare, richcmp_le,
6179-
"__le__($self, value)\n--\n\nReturn self<=value."),
6179+
"__le__($self, value, /)\n--\n\nReturn self<=value."),
61806180
TPSLOT("__eq__", tp_richcompare, slot_tp_richcompare, richcmp_eq,
6181-
"__eq__($self, value)\n--\n\nReturn self==value."),
6181+
"__eq__($self, value, /)\n--\n\nReturn self==value."),
61826182
TPSLOT("__ne__", tp_richcompare, slot_tp_richcompare, richcmp_ne,
6183-
"__ne__($self, value)\n--\n\nReturn self!=value."),
6183+
"__ne__($self, value, /)\n--\n\nReturn self!=value."),
61846184
TPSLOT("__gt__", tp_richcompare, slot_tp_richcompare, richcmp_gt,
6185-
"__gt__($self, value)\n--\n\nReturn self>value."),
6185+
"__gt__($self, value, /)\n--\n\nReturn self>value."),
61866186
TPSLOT("__ge__", tp_richcompare, slot_tp_richcompare, richcmp_ge,
6187-
"__ge__=($self, value)\n--\n\nReturn self>=value."),
6187+
"__ge__=($self, value, /)\n--\n\nReturn self>=value."),
61886188
TPSLOT("__iter__", tp_iter, slot_tp_iter, wrap_unaryfunc,
6189-
"__iter__($self)\n--\n\nImplement iter(self)."),
6189+
"__iter__($self, /)\n--\n\nImplement iter(self)."),
61906190
TPSLOT("__next__", tp_iternext, slot_tp_iternext, wrap_next,
6191-
"__next__($self)\n--\n\nImplement next(self)."),
6191+
"__next__($self, /)\n--\n\nImplement next(self)."),
61926192
TPSLOT("__get__", tp_descr_get, slot_tp_descr_get, wrap_descr_get,
6193-
"__get__($self, instance, owner)\n--\n\nReturn an attribute of instance, which is of type owner."),
6193+
"__get__($self, instance, owner, /)\n--\n\nReturn an attribute of instance, which is of type owner."),
61946194
TPSLOT("__set__", tp_descr_set, slot_tp_descr_set, wrap_descr_set,
6195-
"__set__($self, instance, value)\n--\n\nSet an attribute of instance to value."),
6195+
"__set__($self, instance, value, /)\n--\n\nSet an attribute of instance to value."),
61966196
TPSLOT("__delete__", tp_descr_set, slot_tp_descr_set,
61976197
wrap_descr_delete,
6198-
"__delete__(instance)\n--\n\nDelete an attribute of instance."),
6198+
"__delete__(instance, /)\n--\n\nDelete an attribute of instance."),
61996199
FLSLOT("__init__", tp_init, slot_tp_init, (wrapperfunc)wrap_init,
6200-
"__init__($self, *args, **kwargs)\n--\n\n"
6200+
"__init__($self, /, *args, **kwargs)\n--\n\n"
62016201
"Initialize self. See help(type(self)) for accurate signature.",
62026202
PyWrapperFlag_KEYWORDS),
62036203
TPSLOT("__new__", tp_new, slot_tp_new, NULL,
6204-
"__new__(type, *args, **kwargs)\n--\n\n"
6204+
"__new__(type, /, *args, **kwargs)\n--\n\n"
62056205
"Create and return new object. See help(type) for accurate signature."),
62066206
TPSLOT("__del__", tp_finalize, slot_tp_finalize, (wrapperfunc)wrap_del, ""),
62076207

@@ -6226,9 +6226,9 @@ static slotdef slotdefs[] = {
62266226
RBINSLOTNOTINFIX("__rdivmod__", nb_divmod, slot_nb_divmod,
62276227
"Return divmod(value, self)."),
62286228
NBSLOT("__pow__", nb_power, slot_nb_power, wrap_ternaryfunc,
6229-
"__pow__($self, value, mod=None)\n--\n\nReturn pow(self, value, mod)."),
6229+
"__pow__($self, value, mod=None, /)\n--\n\nReturn pow(self, value, mod)."),
62306230
NBSLOT("__rpow__", nb_power, slot_nb_power, wrap_ternaryfunc_r,
6231-
"__rpow__($self, value, mod=None)\n--\n\nReturn pow(value, self, mod)."),
6231+
"__rpow__($self, value, mod=None, /)\n--\n\nReturn pow(value, self, mod)."),
62326232
UNSLOT("__neg__", nb_negative, slot_nb_negative, wrap_unaryfunc, "-self"),
62336233
UNSLOT("__pos__", nb_positive, slot_nb_positive, wrap_unaryfunc, "+self"),
62346234
UNSLOT("__abs__", nb_absolute, slot_nb_absolute, wrap_unaryfunc,
@@ -6279,48 +6279,48 @@ static slotdef slotdefs[] = {
62796279
IBSLOT("__itruediv__", nb_inplace_true_divide,
62806280
slot_nb_inplace_true_divide, wrap_binaryfunc, "/"),
62816281
NBSLOT("__index__", nb_index, slot_nb_index, wrap_unaryfunc,
6282-
"__index__($self)\n--\n\n"
6282+
"__index__($self, /)\n--\n\n"
62836283
"Return self converted to an integer, if self is suitable"
62846284
"for use as an index into a list."),
62856285
MPSLOT("__len__", mp_length, slot_mp_length, wrap_lenfunc,
6286-
"__len__($self)\n--\n\nReturn len(self)."),
6286+
"__len__($self, /)\n--\n\nReturn len(self)."),
62876287
MPSLOT("__getitem__", mp_subscript, slot_mp_subscript,
62886288
wrap_binaryfunc,
6289-
"__getitem__($self, key)\n--\n\nReturn self[key]."),
6289+
"__getitem__($self, key, /)\n--\n\nReturn self[key]."),
62906290
MPSLOT("__setitem__", mp_ass_subscript, slot_mp_ass_subscript,
62916291
wrap_objobjargproc,
6292-
"__setitem__($self, key, value)\n--\n\nSet self[key] to value."),
6292+
"__setitem__($self, key, value, /)\n--\n\nSet self[key] to value."),
62936293
MPSLOT("__delitem__", mp_ass_subscript, slot_mp_ass_subscript,
62946294
wrap_delitem,
62956295
"__delitem__(key)\n--\n\nDelete self[key]."),
62966296

62976297
SQSLOT("__len__", sq_length, slot_sq_length, wrap_lenfunc,
6298-
"__len__($self)\n--\n\nReturn len(self)."),
6298+
"__len__($self, /)\n--\n\nReturn len(self)."),
62996299
/* Heap types defining __add__/__mul__ have sq_concat/sq_repeat == NULL.
63006300
The logic in abstract.c always falls back to nb_add/nb_multiply in
63016301
this case. Defining both the nb_* and the sq_* slots to call the
63026302
user-defined methods has unexpected side-effects, as shown by
63036303
test_descr.notimplemented() */
63046304
SQSLOT("__add__", sq_concat, NULL, wrap_binaryfunc,
6305-
"__add__($self, value)\n--\n\nReturn self+value."),
6305+
"__add__($self, value, /)\n--\n\nReturn self+value."),
63066306
SQSLOT("__mul__", sq_repeat, NULL, wrap_indexargfunc,
6307-
"__mul__($self, value)\n--\n\nReturn self*value.n"),
6307+
"__mul__($self, value, /)\n--\n\nReturn self*value.n"),
63086308
SQSLOT("__rmul__", sq_repeat, NULL, wrap_indexargfunc,
6309-
"__rmul__($self, value)\n--\n\nReturn self*value."),
6309+
"__rmul__($self, value, /)\n--\n\nReturn self*value."),
63106310
SQSLOT("__getitem__", sq_item, slot_sq_item, wrap_sq_item,
6311-
"__getitem__($self, key)\n--\n\nReturn self[key]."),
6311+
"__getitem__($self, key, /)\n--\n\nReturn self[key]."),
63126312
SQSLOT("__setitem__", sq_ass_item, slot_sq_ass_item, wrap_sq_setitem,
6313-
"__setitem__($self, key, value)\n--\n\nSet self[key] to value."),
6313+
"__setitem__($self, key, value, /)\n--\n\nSet self[key] to value."),
63146314
SQSLOT("__delitem__", sq_ass_item, slot_sq_ass_item, wrap_sq_delitem,
6315-
"__delitem__($self, key)\n--\n\nDelete self[key]."),
6315+
"__delitem__($self, key, /)\n--\n\nDelete self[key]."),
63166316
SQSLOT("__contains__", sq_contains, slot_sq_contains, wrap_objobjproc,
6317-
"__contains__($self, key)\n--\n\nReturn key in self."),
6317+
"__contains__($self, key, /)\n--\n\nReturn key in self."),
63186318
SQSLOT("__iadd__", sq_inplace_concat, NULL,
63196319
wrap_binaryfunc,
6320-
"__iadd__($self, value)\n--\n\nImplement self+=value."),
6320+
"__iadd__($self, value, /)\n--\n\nImplement self+=value."),
63216321
SQSLOT("__imul__", sq_inplace_repeat, NULL,
63226322
wrap_indexargfunc,
6323-
"__imul__($self, value)\n--\n\nImplement self*=value."),
6323+
"__imul__($self, value, /)\n--\n\nImplement self*=value."),
63246324

63256325
{NULL}
63266326
};

0 commit comments

Comments
 (0)