mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
gh-111178: Fix function signatures to fix undefined behavior (#131191)
This commit is contained in:
parent
e4ac196aaa
commit
a5776639c8
5 changed files with 28 additions and 20 deletions
|
|
@ -590,8 +590,9 @@ failed_throw:
|
|||
|
||||
|
||||
static PyObject *
|
||||
gen_throw(PyGenObject *gen, PyObject *const *args, Py_ssize_t nargs)
|
||||
gen_throw(PyObject *op, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyGenObject *gen = _PyGen_CAST(op);
|
||||
PyObject *typ;
|
||||
PyObject *tb = NULL;
|
||||
PyObject *val = NULL;
|
||||
|
|
@ -821,8 +822,9 @@ static PyMemberDef gen_memberlist[] = {
|
|||
};
|
||||
|
||||
static PyObject *
|
||||
gen_sizeof(PyGenObject *gen, PyObject *Py_UNUSED(ignored))
|
||||
gen_sizeof(PyObject *op, PyObject *Py_UNUSED(ignored))
|
||||
{
|
||||
PyGenObject *gen = _PyGen_CAST(op);
|
||||
Py_ssize_t res;
|
||||
res = offsetof(PyGenObject, gi_iframe) + offsetof(_PyInterpreterFrame, localsplus);
|
||||
PyCodeObject *code = _PyGen_GetCode(gen);
|
||||
|
|
@ -837,7 +839,7 @@ static PyMethodDef gen_methods[] = {
|
|||
{"send", gen_send, METH_O, send_doc},
|
||||
{"throw", _PyCFunction_CAST(gen_throw), METH_FASTCALL, throw_doc},
|
||||
{"close", gen_close, METH_NOARGS, close_doc},
|
||||
{"__sizeof__", (PyCFunction)gen_sizeof, METH_NOARGS, sizeof__doc__},
|
||||
{"__sizeof__", gen_sizeof, METH_NOARGS, sizeof__doc__},
|
||||
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
||||
{NULL, NULL} /* Sentinel */
|
||||
};
|
||||
|
|
@ -1197,7 +1199,7 @@ static PyMethodDef coro_methods[] = {
|
|||
{"send", gen_send, METH_O, coro_send_doc},
|
||||
{"throw",_PyCFunction_CAST(gen_throw), METH_FASTCALL, coro_throw_doc},
|
||||
{"close", gen_close, METH_NOARGS, coro_close_doc},
|
||||
{"__sizeof__", (PyCFunction)gen_sizeof, METH_NOARGS, sizeof__doc__},
|
||||
{"__sizeof__", gen_sizeof, METH_NOARGS, sizeof__doc__},
|
||||
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
||||
{NULL, NULL} /* Sentinel */
|
||||
};
|
||||
|
|
@ -1288,7 +1290,7 @@ static PyObject *
|
|||
coro_wrapper_throw(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyCoroWrapper *cw = _PyCoroWrapper_CAST(self);
|
||||
return gen_throw((PyGenObject *)cw->cw_coroutine, args, nargs);
|
||||
return gen_throw((PyObject*)cw->cw_coroutine, args, nargs);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
|
|
@ -1625,7 +1627,7 @@ static PyMethodDef async_gen_methods[] = {
|
|||
{"asend", (PyCFunction)async_gen_asend, METH_O, async_asend_doc},
|
||||
{"athrow",(PyCFunction)async_gen_athrow, METH_VARARGS, async_athrow_doc},
|
||||
{"aclose", (PyCFunction)async_gen_aclose, METH_NOARGS, async_aclose_doc},
|
||||
{"__sizeof__", (PyCFunction)gen_sizeof, METH_NOARGS, sizeof__doc__},
|
||||
{"__sizeof__", gen_sizeof, METH_NOARGS, sizeof__doc__},
|
||||
{"__class_getitem__", Py_GenericAlias,
|
||||
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
||||
{NULL, NULL} /* Sentinel */
|
||||
|
|
@ -1842,7 +1844,7 @@ async_gen_asend_throw(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
|
|||
o->ags_gen->ag_running_async = 1;
|
||||
}
|
||||
|
||||
PyObject *result = gen_throw((PyGenObject*)o->ags_gen, args, nargs);
|
||||
PyObject *result = gen_throw((PyObject*)o->ags_gen, args, nargs);
|
||||
result = async_gen_unwrap_value(o->ags_gen, result);
|
||||
|
||||
if (result == NULL) {
|
||||
|
|
@ -2249,7 +2251,7 @@ async_gen_athrow_throw(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
|
|||
o->agt_gen->ag_running_async = 1;
|
||||
}
|
||||
|
||||
PyObject *retval = gen_throw((PyGenObject*)o->agt_gen, args, nargs);
|
||||
PyObject *retval = gen_throw((PyObject*)o->agt_gen, args, nargs);
|
||||
if (o->agt_args) {
|
||||
retval = async_gen_unwrap_value(o->agt_gen, retval);
|
||||
if (retval == NULL) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue