mirror of
https://github.com/python/cpython
synced 2026-09-29 10:35:30 +03:00
bpo-33029: Fix signatures of getter and setter functions. (GH-10746)
Fix also return type for few other functions (clear, releasebuffer).
This commit is contained in:
parent
1005c84535
commit
d4f9cf5545
25 changed files with 128 additions and 122 deletions
|
|
@ -112,7 +112,7 @@ cell_get_contents(PyCellObject *op, void *closure)
|
|||
}
|
||||
|
||||
static int
|
||||
cell_set_contents(PyCellObject *op, PyObject *obj)
|
||||
cell_set_contents(PyCellObject *op, PyObject *obj, void *Py_UNUSED(ignored))
|
||||
{
|
||||
Py_XINCREF(obj);
|
||||
Py_XSETREF(op->ob_ref, obj);
|
||||
|
|
|
|||
|
|
@ -441,7 +441,7 @@ calculate_qualname(PyDescrObject *descr)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
descr_get_qualname(PyDescrObject *descr)
|
||||
descr_get_qualname(PyDescrObject *descr, void *Py_UNUSED(ignored))
|
||||
{
|
||||
if (descr->d_qualname == NULL)
|
||||
descr->d_qualname = calculate_qualname(descr);
|
||||
|
|
@ -1107,7 +1107,7 @@ static PyMemberDef wrapper_members[] = {
|
|||
};
|
||||
|
||||
static PyObject *
|
||||
wrapper_objclass(wrapperobject *wp)
|
||||
wrapper_objclass(wrapperobject *wp, void *Py_UNUSED(ignored))
|
||||
{
|
||||
PyObject *c = (PyObject *)PyDescr_TYPE(wp->descr);
|
||||
|
||||
|
|
@ -1116,7 +1116,7 @@ wrapper_objclass(wrapperobject *wp)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
wrapper_name(wrapperobject *wp)
|
||||
wrapper_name(wrapperobject *wp, void *Py_UNUSED(ignored))
|
||||
{
|
||||
const char *s = wp->descr->d_base->name;
|
||||
|
||||
|
|
@ -1124,21 +1124,21 @@ wrapper_name(wrapperobject *wp)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
wrapper_doc(wrapperobject *wp, void *closure)
|
||||
wrapper_doc(wrapperobject *wp, void *Py_UNUSED(ignored))
|
||||
{
|
||||
return _PyType_GetDocFromInternalDoc(wp->descr->d_base->name, wp->descr->d_base->doc);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
wrapper_text_signature(wrapperobject *wp, void *closure)
|
||||
wrapper_text_signature(wrapperobject *wp, void *Py_UNUSED(ignored))
|
||||
{
|
||||
return _PyType_GetTextSignatureFromInternalDoc(wp->descr->d_base->name, wp->descr->d_base->doc);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
wrapper_qualname(wrapperobject *wp)
|
||||
wrapper_qualname(wrapperobject *wp, void *Py_UNUSED(ignored))
|
||||
{
|
||||
return descr_get_qualname((PyDescrObject *)wp->descr);
|
||||
return descr_get_qualname((PyDescrObject *)wp->descr, NULL);
|
||||
}
|
||||
|
||||
static PyGetSetDef wrapper_getsets[] = {
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ static PyMethodDef BaseException_methods[] = {
|
|||
};
|
||||
|
||||
static PyObject *
|
||||
BaseException_get_args(PyBaseExceptionObject *self)
|
||||
BaseException_get_args(PyBaseExceptionObject *self, void *Py_UNUSED(ignored))
|
||||
{
|
||||
if (self->args == NULL) {
|
||||
Py_RETURN_NONE;
|
||||
|
|
@ -192,7 +192,7 @@ BaseException_get_args(PyBaseExceptionObject *self)
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
@ -207,7 +207,7 @@ BaseException_set_args(PyBaseExceptionObject *self, PyObject *val)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
BaseException_get_tb(PyBaseExceptionObject *self)
|
||||
BaseException_get_tb(PyBaseExceptionObject *self, void *Py_UNUSED(ignored))
|
||||
{
|
||||
if (self->traceback == NULL) {
|
||||
Py_RETURN_NONE;
|
||||
|
|
@ -217,7 +217,7 @@ BaseException_get_tb(PyBaseExceptionObject *self)
|
|||
}
|
||||
|
||||
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");
|
||||
|
|
@ -235,7 +235,8 @@ BaseException_set_tb(PyBaseExceptionObject *self, PyObject *tb)
|
|||
}
|
||||
|
||||
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 */
|
||||
|
|
@ -243,7 +244,8 @@ BaseException_get_context(PyObject *self) {
|
|||
}
|
||||
|
||||
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;
|
||||
|
|
@ -262,7 +264,8 @@ BaseException_set_context(PyObject *self, PyObject *arg) {
|
|||
}
|
||||
|
||||
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 */
|
||||
|
|
@ -270,7 +273,8 @@ BaseException_get_cause(PyObject *self) {
|
|||
}
|
||||
|
||||
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;
|
||||
|
|
@ -293,10 +297,10 @@ static PyGetSetDef BaseException_getset[] = {
|
|||
{"__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},
|
||||
};
|
||||
|
||||
|
|
@ -311,7 +315,7 @@ PyException_GetTraceback(PyObject *self) {
|
|||
|
||||
int
|
||||
PyException_SetTraceback(PyObject *self, PyObject *tb) {
|
||||
return BaseException_set_tb((PyBaseExceptionObject *)self, tb);
|
||||
return BaseException_set_tb((PyBaseExceptionObject *)self, tb, NULL);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ get_arg(const _Py_CODEUNIT *codestr, Py_ssize_t i)
|
|||
* that time.
|
||||
*/
|
||||
static int
|
||||
frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
|
||||
frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno, void *Py_UNUSED(ignored))
|
||||
{
|
||||
int new_lineno = 0; /* The new value of f_lineno */
|
||||
long l_new_lineno;
|
||||
|
|
@ -470,7 +470,7 @@ frame_traverse(PyFrameObject *f, visitproc visit, void *arg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
static int
|
||||
frame_tp_clear(PyFrameObject *f)
|
||||
{
|
||||
PyObject **fastlocals, **p, **oldtop;
|
||||
|
|
@ -498,6 +498,7 @@ frame_tp_clear(PyFrameObject *f)
|
|||
for (p = f->f_valuestack; p < oldtop; p++)
|
||||
Py_CLEAR(*p);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
|
@ -512,7 +513,7 @@ frame_clear(PyFrameObject *f, PyObject *Py_UNUSED(ignored))
|
|||
_PyGen_Finalize(f->f_gen);
|
||||
assert(f->f_gen == NULL);
|
||||
}
|
||||
frame_tp_clear(f);
|
||||
(void)frame_tp_clear(f);
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -244,14 +244,14 @@ static PyMemberDef func_memberlist[] = {
|
|||
};
|
||||
|
||||
static PyObject *
|
||||
func_get_code(PyFunctionObject *op)
|
||||
func_get_code(PyFunctionObject *op, void *Py_UNUSED(ignored))
|
||||
{
|
||||
Py_INCREF(op->func_code);
|
||||
return op->func_code;
|
||||
}
|
||||
|
||||
static int
|
||||
func_set_code(PyFunctionObject *op, PyObject *value)
|
||||
func_set_code(PyFunctionObject *op, PyObject *value, void *Py_UNUSED(ignored))
|
||||
{
|
||||
Py_ssize_t nfree, nclosure;
|
||||
|
||||
|
|
@ -279,14 +279,14 @@ func_set_code(PyFunctionObject *op, PyObject *value)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
func_get_name(PyFunctionObject *op)
|
||||
func_get_name(PyFunctionObject *op, void *Py_UNUSED(ignored))
|
||||
{
|
||||
Py_INCREF(op->func_name);
|
||||
return op->func_name;
|
||||
}
|
||||
|
||||
static int
|
||||
func_set_name(PyFunctionObject *op, PyObject *value)
|
||||
func_set_name(PyFunctionObject *op, PyObject *value, void *Py_UNUSED(ignored))
|
||||
{
|
||||
/* Not legal to del f.func_name or to set it to anything
|
||||
* other than a string object. */
|
||||
|
|
@ -301,14 +301,14 @@ func_set_name(PyFunctionObject *op, PyObject *value)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
func_get_qualname(PyFunctionObject *op)
|
||||
func_get_qualname(PyFunctionObject *op, void *Py_UNUSED(ignored))
|
||||
{
|
||||
Py_INCREF(op->func_qualname);
|
||||
return op->func_qualname;
|
||||
}
|
||||
|
||||
static int
|
||||
func_set_qualname(PyFunctionObject *op, PyObject *value)
|
||||
func_set_qualname(PyFunctionObject *op, PyObject *value, void *Py_UNUSED(ignored))
|
||||
{
|
||||
/* Not legal to del f.__qualname__ or to set it to anything
|
||||
* other than a string object. */
|
||||
|
|
@ -323,7 +323,7 @@ func_set_qualname(PyFunctionObject *op, PyObject *value)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
func_get_defaults(PyFunctionObject *op)
|
||||
func_get_defaults(PyFunctionObject *op, void *Py_UNUSED(ignored))
|
||||
{
|
||||
if (op->func_defaults == NULL) {
|
||||
Py_RETURN_NONE;
|
||||
|
|
@ -333,7 +333,7 @@ func_get_defaults(PyFunctionObject *op)
|
|||
}
|
||||
|
||||
static int
|
||||
func_set_defaults(PyFunctionObject *op, PyObject *value)
|
||||
func_set_defaults(PyFunctionObject *op, PyObject *value, void *Py_UNUSED(ignored))
|
||||
{
|
||||
/* Legal to del f.func_defaults.
|
||||
* Can only set func_defaults to NULL or a tuple. */
|
||||
|
|
@ -350,7 +350,7 @@ func_set_defaults(PyFunctionObject *op, PyObject *value)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
func_get_kwdefaults(PyFunctionObject *op)
|
||||
func_get_kwdefaults(PyFunctionObject *op, void *Py_UNUSED(ignored))
|
||||
{
|
||||
if (op->func_kwdefaults == NULL) {
|
||||
Py_RETURN_NONE;
|
||||
|
|
@ -360,7 +360,7 @@ func_get_kwdefaults(PyFunctionObject *op)
|
|||
}
|
||||
|
||||
static int
|
||||
func_set_kwdefaults(PyFunctionObject *op, PyObject *value)
|
||||
func_set_kwdefaults(PyFunctionObject *op, PyObject *value, void *Py_UNUSED(ignored))
|
||||
{
|
||||
if (value == Py_None)
|
||||
value = NULL;
|
||||
|
|
@ -377,7 +377,7 @@ func_set_kwdefaults(PyFunctionObject *op, PyObject *value)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
func_get_annotations(PyFunctionObject *op)
|
||||
func_get_annotations(PyFunctionObject *op, void *Py_UNUSED(ignored))
|
||||
{
|
||||
if (op->func_annotations == NULL) {
|
||||
op->func_annotations = PyDict_New();
|
||||
|
|
@ -389,7 +389,7 @@ func_get_annotations(PyFunctionObject *op)
|
|||
}
|
||||
|
||||
static int
|
||||
func_set_annotations(PyFunctionObject *op, PyObject *value)
|
||||
func_set_annotations(PyFunctionObject *op, PyObject *value, void *Py_UNUSED(ignored))
|
||||
{
|
||||
if (value == Py_None)
|
||||
value = NULL;
|
||||
|
|
|
|||
|
|
@ -645,14 +645,14 @@ gen_repr(PyGenObject *gen)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
gen_get_name(PyGenObject *op)
|
||||
gen_get_name(PyGenObject *op, void *Py_UNUSED(ignored))
|
||||
{
|
||||
Py_INCREF(op->gi_name);
|
||||
return op->gi_name;
|
||||
}
|
||||
|
||||
static int
|
||||
gen_set_name(PyGenObject *op, PyObject *value)
|
||||
gen_set_name(PyGenObject *op, PyObject *value, void *Py_UNUSED(ignored))
|
||||
{
|
||||
/* Not legal to del gen.gi_name or to set it to anything
|
||||
* other than a string object. */
|
||||
|
|
@ -667,14 +667,14 @@ gen_set_name(PyGenObject *op, PyObject *value)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
gen_get_qualname(PyGenObject *op)
|
||||
gen_get_qualname(PyGenObject *op, void *Py_UNUSED(ignored))
|
||||
{
|
||||
Py_INCREF(op->gi_qualname);
|
||||
return op->gi_qualname;
|
||||
}
|
||||
|
||||
static int
|
||||
gen_set_qualname(PyGenObject *op, PyObject *value)
|
||||
gen_set_qualname(PyGenObject *op, PyObject *value, void *Py_UNUSED(ignored))
|
||||
{
|
||||
/* Not legal to del gen.__qualname__ or to set it to anything
|
||||
* other than a string object. */
|
||||
|
|
@ -689,7 +689,7 @@ gen_set_qualname(PyGenObject *op, PyObject *value)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
gen_getyieldfrom(PyGenObject *gen)
|
||||
gen_getyieldfrom(PyGenObject *gen, void *Py_UNUSED(ignored))
|
||||
{
|
||||
PyObject *yf = _PyGen_yf(gen);
|
||||
if (yf == NULL)
|
||||
|
|
@ -926,7 +926,7 @@ coro_await(PyCoroObject *coro)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
coro_get_cr_await(PyCoroObject *coro)
|
||||
coro_get_cr_await(PyCoroObject *coro, void *Py_UNUSED(ignored))
|
||||
{
|
||||
PyObject *yf = _PyGen_yf((PyGenObject *) coro);
|
||||
if (yf == NULL)
|
||||
|
|
|
|||
|
|
@ -2920,7 +2920,7 @@ _IntTupleFromSsizet(int len, Py_ssize_t *vals)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
memory_obj_get(PyMemoryViewObject *self)
|
||||
memory_obj_get(PyMemoryViewObject *self, void *Py_UNUSED(ignored))
|
||||
{
|
||||
Py_buffer *view = &self->view;
|
||||
|
||||
|
|
@ -2933,56 +2933,56 @@ memory_obj_get(PyMemoryViewObject *self)
|
|||
}
|
||||
|
||||
static PyObject *
|
||||
memory_nbytes_get(PyMemoryViewObject *self)
|
||||
memory_nbytes_get(PyMemoryViewObject *self, void *Py_UNUSED(ignored))
|
||||
{
|
||||
CHECK_RELEASED(self);
|
||||
return PyLong_FromSsize_t(self->view.len);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
memory_format_get(PyMemoryViewObject *self)
|
||||
memory_format_get(PyMemoryViewObject *self, void *Py_UNUSED(ignored))
|
||||
{
|
||||
CHECK_RELEASED(self);
|
||||
return PyUnicode_FromString(self->view.format);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
memory_itemsize_get(PyMemoryViewObject *self)
|
||||
memory_itemsize_get(PyMemoryViewObject *self, void *Py_UNUSED(ignored))
|
||||
{
|
||||
CHECK_RELEASED(self);
|
||||
return PyLong_FromSsize_t(self->view.itemsize);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
memory_shape_get(PyMemoryViewObject *self)
|
||||
memory_shape_get(PyMemoryViewObject *self, void *Py_UNUSED(ignored))
|
||||
{
|
||||
CHECK_RELEASED(self);
|
||||
return _IntTupleFromSsizet(self->view.ndim, self->view.shape);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
memory_strides_get(PyMemoryViewObject *self)
|
||||
memory_strides_get(PyMemoryViewObject *self, void *Py_UNUSED(ignored))
|
||||
{
|
||||
CHECK_RELEASED(self);
|
||||
return _IntTupleFromSsizet(self->view.ndim, self->view.strides);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
memory_suboffsets_get(PyMemoryViewObject *self)
|
||||
memory_suboffsets_get(PyMemoryViewObject *self, void *Py_UNUSED(ignored))
|
||||
{
|
||||
CHECK_RELEASED(self);
|
||||
return _IntTupleFromSsizet(self->view.ndim, self->view.suboffsets);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
memory_readonly_get(PyMemoryViewObject *self)
|
||||
memory_readonly_get(PyMemoryViewObject *self, void *Py_UNUSED(ignored))
|
||||
{
|
||||
CHECK_RELEASED(self);
|
||||
return PyBool_FromLong(self->view.readonly);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
memory_ndim_get(PyMemoryViewObject *self)
|
||||
memory_ndim_get(PyMemoryViewObject *self, void *Py_UNUSED(ignored))
|
||||
{
|
||||
CHECK_RELEASED(self);
|
||||
return PyLong_FromLong(self->view.ndim);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue