Skip to content

Commit

Permalink
pythongh-123446: Fix empty function names in TypeErrors in `typeobj…
Browse files Browse the repository at this point in the history
…ect`
  • Loading branch information
sobolevn committed Aug 29, 2024
1 parent 58ce131 commit 2411d03
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix empty function name in :exc:`TypeError` when builtin magic methods are
used without the required args.
20 changes: 10 additions & 10 deletions Objects/typeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -8759,7 +8759,7 @@ wrap_ternaryfunc(PyObject *self, PyObject *args, void *wrapped)

/* Note: This wrapper only works for __pow__() */

if (!PyArg_UnpackTuple(args, "", 1, 2, &other, &third))
if (!PyArg_UnpackTuple(args, "__pow__", 1, 2, &other, &third))
return NULL;
return (*func)(self, other, third);
}
Expand All @@ -8773,7 +8773,7 @@ wrap_ternaryfunc_r(PyObject *self, PyObject *args, void *wrapped)

/* Note: This wrapper only works for __pow__() */

if (!PyArg_UnpackTuple(args, "", 1, 2, &other, &third))
if (!PyArg_UnpackTuple(args, "__rpow__", 1, 2, &other, &third))
return NULL;
return (*func)(other, self, third);
}
Expand All @@ -8795,7 +8795,7 @@ wrap_indexargfunc(PyObject *self, PyObject *args, void *wrapped)
PyObject* o;
Py_ssize_t i;

if (!PyArg_UnpackTuple(args, "", 1, 1, &o))
if (!PyArg_UnpackTuple(args, "__mul__", 1, 1, &o))
return NULL;
i = PyNumber_AsSsize_t(o, PyExc_OverflowError);
if (i == -1 && PyErr_Occurred())
Expand Down Expand Up @@ -8852,7 +8852,7 @@ wrap_sq_setitem(PyObject *self, PyObject *args, void *wrapped)
int res;
PyObject *arg, *value;

if (!PyArg_UnpackTuple(args, "", 2, 2, &arg, &value))
if (!PyArg_UnpackTuple(args, "__setitem__", 2, 2, &arg, &value))
return NULL;
i = getindex(self, arg);
if (i == -1 && PyErr_Occurred())
Expand Down Expand Up @@ -8908,7 +8908,7 @@ wrap_objobjargproc(PyObject *self, PyObject *args, void *wrapped)
int res;
PyObject *key, *value;

if (!PyArg_UnpackTuple(args, "", 2, 2, &key, &value))
if (!PyArg_UnpackTuple(args, "__setitem__", 2, 2, &key, &value))
return NULL;
res = (*func)(self, key, value);
if (res == -1 && PyErr_Occurred())
Expand Down Expand Up @@ -9005,7 +9005,7 @@ wrap_setattr(PyObject *self, PyObject *args, void *wrapped)
int res;
PyObject *name, *value;

if (!PyArg_UnpackTuple(args, "", 2, 2, &name, &value))
if (!PyArg_UnpackTuple(args, "__setattr__", 2, 2, &name, &value))
return NULL;
if (!hackcheck(self, func, "__setattr__"))
return NULL;
Expand Down Expand Up @@ -9115,7 +9115,7 @@ wrap_descr_get(PyObject *self, PyObject *args, void *wrapped)
PyObject *obj;
PyObject *type = NULL;

if (!PyArg_UnpackTuple(args, "", 1, 2, &obj, &type))
if (!PyArg_UnpackTuple(args, "__get__", 1, 2, &obj, &type))
return NULL;
if (obj == Py_None)
obj = NULL;
Expand All @@ -9136,7 +9136,7 @@ wrap_descr_set(PyObject *self, PyObject *args, void *wrapped)
PyObject *obj, *value;
int ret;

if (!PyArg_UnpackTuple(args, "", 2, 2, &obj, &value))
if (!PyArg_UnpackTuple(args, "__set__", 2, 2, &obj, &value))
return NULL;
ret = (*func)(self, obj, value);
if (ret < 0)
Expand Down Expand Up @@ -9165,7 +9165,7 @@ wrap_buffer(PyObject *self, PyObject *args, void *wrapped)
{
PyObject *arg = NULL;

if (!PyArg_UnpackTuple(args, "", 1, 1, &arg)) {
if (!PyArg_UnpackTuple(args, "__buffer__", 1, 1, &arg)) {
return NULL;
}
Py_ssize_t flags = PyNumber_AsSsize_t(arg, PyExc_OverflowError);
Expand All @@ -9186,7 +9186,7 @@ static PyObject *
wrap_releasebuffer(PyObject *self, PyObject *args, void *wrapped)
{
PyObject *arg = NULL;
if (!PyArg_UnpackTuple(args, "", 1, 1, &arg)) {
if (!PyArg_UnpackTuple(args, "__release_buffer__", 1, 1, &arg)) {
return NULL;
}
if (!PyMemoryView_Check(arg)) {
Expand Down

0 comments on commit 2411d03

Please sign in to comment.