bpo-33029: Fix signatures of getter and setter functions. (GH-10746)
Fix also return type for few other functions (clear, releasebuffer).
(cherry picked from commit d4f9cf5545d6d8844e0726552ef2e366f5cc3abd)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
diff --git a/Objects/exceptions.c b/Objects/exceptions.c
index 2cce40f..03bdf79 100644
--- a/Objects/exceptions.c
+++ b/Objects/exceptions.c
@@ -181,7 +181,7 @@
};
static PyObject *
-BaseException_get_args(PyBaseExceptionObject *self)
+BaseException_get_args(PyBaseExceptionObject *self, void *Py_UNUSED(ignored))
{
if (self->args == NULL) {
Py_RETURN_NONE;
@@ -191,7 +191,7 @@
}
static int
-BaseException_set_args(PyBaseExceptionObject *self, PyObject *val)
+BaseException_set_args(PyBaseExceptionObject *self, PyObject *val, void *Py_UNUSED(ignored))
{
PyObject *seq;
if (val == NULL) {
@@ -206,7 +206,7 @@
}
static PyObject *
-BaseException_get_tb(PyBaseExceptionObject *self)
+BaseException_get_tb(PyBaseExceptionObject *self, void *Py_UNUSED(ignored))
{
if (self->traceback == NULL) {
Py_RETURN_NONE;
@@ -216,7 +216,7 @@
}
static int
-BaseException_set_tb(PyBaseExceptionObject *self, PyObject *tb)
+BaseException_set_tb(PyBaseExceptionObject *self, PyObject *tb, void *Py_UNUSED(ignored))
{
if (tb == NULL) {
PyErr_SetString(PyExc_TypeError, "__traceback__ may not be deleted");
@@ -234,7 +234,8 @@
}
static PyObject *
-BaseException_get_context(PyObject *self) {
+BaseException_get_context(PyObject *self, void *Py_UNUSED(ignored))
+{
PyObject *res = PyException_GetContext(self);
if (res)
return res; /* new reference already returned above */
@@ -242,7 +243,8 @@
}
static int
-BaseException_set_context(PyObject *self, PyObject *arg) {
+BaseException_set_context(PyObject *self, PyObject *arg, void *Py_UNUSED(ignored))
+{
if (arg == NULL) {
PyErr_SetString(PyExc_TypeError, "__context__ may not be deleted");
return -1;
@@ -261,7 +263,8 @@
}
static PyObject *
-BaseException_get_cause(PyObject *self) {
+BaseException_get_cause(PyObject *self, void *Py_UNUSED(ignored))
+{
PyObject *res = PyException_GetCause(self);
if (res)
return res; /* new reference already returned above */
@@ -269,7 +272,8 @@
}
static int
-BaseException_set_cause(PyObject *self, PyObject *arg) {
+BaseException_set_cause(PyObject *self, PyObject *arg, void *Py_UNUSED(ignored))
+{
if (arg == NULL) {
PyErr_SetString(PyExc_TypeError, "__cause__ may not be deleted");
return -1;
@@ -292,10 +296,10 @@
{"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict},
{"args", (getter)BaseException_get_args, (setter)BaseException_set_args},
{"__traceback__", (getter)BaseException_get_tb, (setter)BaseException_set_tb},
- {"__context__", (getter)BaseException_get_context,
- (setter)BaseException_set_context, PyDoc_STR("exception context")},
- {"__cause__", (getter)BaseException_get_cause,
- (setter)BaseException_set_cause, PyDoc_STR("exception cause")},
+ {"__context__", BaseException_get_context,
+ BaseException_set_context, PyDoc_STR("exception context")},
+ {"__cause__", BaseException_get_cause,
+ BaseException_set_cause, PyDoc_STR("exception cause")},
{NULL},
};
@@ -310,7 +314,7 @@
int
PyException_SetTraceback(PyObject *self, PyObject *tb) {
- return BaseException_set_tb((PyBaseExceptionObject *)self, tb);
+ return BaseException_set_tb((PyBaseExceptionObject *)self, tb, NULL);
}
PyObject *