mirror of
https://github.com/python/cpython.git
synced 2025-12-09 10:37:17 +00:00
gh-111178: Change Argument Clinic signature for METH_O (#130682)
Use "PyObject*" for METH_O functions to fix an undefined behavior.
This commit is contained in:
parent
4162bc133b
commit
9d759b63d8
66 changed files with 843 additions and 190 deletions
|
|
@ -1303,8 +1303,8 @@ This is guaranteed to be unique among simultaneously existing objects.
|
|||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
builtin_id(PyModuleDef *self, PyObject *v)
|
||||
/*[clinic end generated code: output=0aa640785f697f65 input=5a534136419631f4]*/
|
||||
builtin_id_impl(PyModuleDef *self, PyObject *v)
|
||||
/*[clinic end generated code: output=4908a6782ed343e9 input=5a534136419631f4]*/
|
||||
{
|
||||
PyObject *id = PyLong_FromVoidPtr(v);
|
||||
|
||||
|
|
|
|||
15
Python/clinic/bltinmodule.c.h
generated
15
Python/clinic/bltinmodule.c.h
generated
|
|
@ -628,6 +628,19 @@ PyDoc_STRVAR(builtin_id__doc__,
|
|||
#define BUILTIN_ID_METHODDEF \
|
||||
{"id", (PyCFunction)builtin_id, METH_O, builtin_id__doc__},
|
||||
|
||||
static PyObject *
|
||||
builtin_id_impl(PyModuleDef *self, PyObject *v);
|
||||
|
||||
static PyObject *
|
||||
builtin_id(PyObject *self, PyObject *v)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
|
||||
return_value = builtin_id_impl((PyModuleDef *)self, v);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(builtin_setattr__doc__,
|
||||
"setattr($module, obj, name, value, /)\n"
|
||||
"--\n"
|
||||
|
|
@ -1239,4 +1252,4 @@ builtin_issubclass(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=b0178189d13e8bf8 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=c08e0e086a791ff0 input=a9049054013a1b77]*/
|
||||
|
|
|
|||
28
Python/clinic/context.c.h
generated
28
Python/clinic/context.c.h
generated
|
|
@ -168,6 +168,19 @@ PyDoc_STRVAR(_contextvars_ContextVar_set__doc__,
|
|||
#define _CONTEXTVARS_CONTEXTVAR_SET_METHODDEF \
|
||||
{"set", (PyCFunction)_contextvars_ContextVar_set, METH_O, _contextvars_ContextVar_set__doc__},
|
||||
|
||||
static PyObject *
|
||||
_contextvars_ContextVar_set_impl(PyContextVar *self, PyObject *value);
|
||||
|
||||
static PyObject *
|
||||
_contextvars_ContextVar_set(PyObject *self, PyObject *value)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
|
||||
return_value = _contextvars_ContextVar_set_impl((PyContextVar *)self, value);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(_contextvars_ContextVar_reset__doc__,
|
||||
"reset($self, token, /)\n"
|
||||
"--\n"
|
||||
|
|
@ -180,6 +193,19 @@ PyDoc_STRVAR(_contextvars_ContextVar_reset__doc__,
|
|||
#define _CONTEXTVARS_CONTEXTVAR_RESET_METHODDEF \
|
||||
{"reset", (PyCFunction)_contextvars_ContextVar_reset, METH_O, _contextvars_ContextVar_reset__doc__},
|
||||
|
||||
static PyObject *
|
||||
_contextvars_ContextVar_reset_impl(PyContextVar *self, PyObject *token);
|
||||
|
||||
static PyObject *
|
||||
_contextvars_ContextVar_reset(PyObject *self, PyObject *token)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
|
||||
return_value = _contextvars_ContextVar_reset_impl((PyContextVar *)self, token);
|
||||
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(token_enter__doc__,
|
||||
"__enter__($self, /)\n"
|
||||
"--\n"
|
||||
|
|
@ -230,4 +256,4 @@ token_exit(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
|
|||
exit:
|
||||
return return_value;
|
||||
}
|
||||
/*[clinic end generated code: output=01987cdbf68a951a input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=3a04b2fddf24c3e9 input=a9049054013a1b77]*/
|
||||
|
|
|
|||
|
|
@ -1058,8 +1058,8 @@ value via the `ContextVar.reset()` method.
|
|||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_contextvars_ContextVar_set(PyContextVar *self, PyObject *value)
|
||||
/*[clinic end generated code: output=446ed5e820d6d60b input=c0a6887154227453]*/
|
||||
_contextvars_ContextVar_set_impl(PyContextVar *self, PyObject *value)
|
||||
/*[clinic end generated code: output=1b562d35cc79c806 input=c0a6887154227453]*/
|
||||
{
|
||||
return PyContextVar_Set((PyObject *)self, value);
|
||||
}
|
||||
|
|
@ -1076,8 +1076,8 @@ created the token was used.
|
|||
[clinic start generated code]*/
|
||||
|
||||
static PyObject *
|
||||
_contextvars_ContextVar_reset(PyContextVar *self, PyObject *token)
|
||||
/*[clinic end generated code: output=d4ee34d0742d62ee input=ebe2881e5af4ffda]*/
|
||||
_contextvars_ContextVar_reset_impl(PyContextVar *self, PyObject *token)
|
||||
/*[clinic end generated code: output=3205d2bdff568521 input=ebe2881e5af4ffda]*/
|
||||
{
|
||||
if (!PyContextToken_CheckExact(token)) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue