mirror of
https://github.com/python/cpython.git
synced 2025-09-27 18:59:43 +00:00
Clean up initialization __class_getitem__ with Py_GenericAlias. (GH-28450)
The cast to PyCFunction is redundant. Overuse of redundant casts can hide actual bugs.
This commit is contained in:
parent
a624177386
commit
f25f2e2e8c
17 changed files with 21 additions and 21 deletions
|
@ -31,7 +31,7 @@ two types exist -- :ref:`GenericAlias <types-genericalias>` and
|
||||||
static PyMethodDef my_obj_methods[] = {
|
static PyMethodDef my_obj_methods[] = {
|
||||||
// Other methods.
|
// Other methods.
|
||||||
...
|
...
|
||||||
{"__class_getitem__", (PyCFunction)Py_GenericAlias, METH_O|METH_CLASS, "See PEP 585"}
|
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, "See PEP 585"}
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1636,7 +1636,7 @@ static PyMethodDef deque_methods[] = {
|
||||||
METH_FASTCALL, rotate_doc},
|
METH_FASTCALL, rotate_doc},
|
||||||
{"__sizeof__", (PyCFunction)deque_sizeof,
|
{"__sizeof__", (PyCFunction)deque_sizeof,
|
||||||
METH_NOARGS, sizeof_doc},
|
METH_NOARGS, sizeof_doc},
|
||||||
{"__class_getitem__", (PyCFunction)Py_GenericAlias,
|
{"__class_getitem__", Py_GenericAlias,
|
||||||
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
@ -2104,7 +2104,7 @@ static PyMethodDef defdict_methods[] = {
|
||||||
defdict_copy_doc},
|
defdict_copy_doc},
|
||||||
{"__reduce__", (PyCFunction)defdict_reduce, METH_NOARGS,
|
{"__reduce__", (PyCFunction)defdict_reduce, METH_NOARGS,
|
||||||
reduce_doc},
|
reduce_doc},
|
||||||
{"__class_getitem__", (PyCFunction)Py_GenericAlias, METH_O|METH_CLASS,
|
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS,
|
||||||
PyDoc_STR("See PEP 585")},
|
PyDoc_STR("See PEP 585")},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
|
@ -4795,7 +4795,7 @@ Array_length(PyObject *myself)
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyMethodDef Array_methods[] = {
|
static PyMethodDef Array_methods[] = {
|
||||||
{"__class_getitem__", (PyCFunction)Py_GenericAlias,
|
{"__class_getitem__", Py_GenericAlias,
|
||||||
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
|
@ -465,7 +465,7 @@ partial_setstate(partialobject *pto, PyObject *state)
|
||||||
static PyMethodDef partial_methods[] = {
|
static PyMethodDef partial_methods[] = {
|
||||||
{"__reduce__", (PyCFunction)partial_reduce, METH_NOARGS},
|
{"__reduce__", (PyCFunction)partial_reduce, METH_NOARGS},
|
||||||
{"__setstate__", (PyCFunction)partial_setstate, METH_O},
|
{"__setstate__", (PyCFunction)partial_setstate, METH_O},
|
||||||
{"__class_getitem__", (PyCFunction)Py_GenericAlias,
|
{"__class_getitem__", Py_GenericAlias,
|
||||||
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
|
@ -356,7 +356,7 @@ static PyMethodDef simplequeue_methods[] = {
|
||||||
_QUEUE_SIMPLEQUEUE_PUT_METHODDEF
|
_QUEUE_SIMPLEQUEUE_PUT_METHODDEF
|
||||||
_QUEUE_SIMPLEQUEUE_PUT_NOWAIT_METHODDEF
|
_QUEUE_SIMPLEQUEUE_PUT_NOWAIT_METHODDEF
|
||||||
_QUEUE_SIMPLEQUEUE_QSIZE_METHODDEF
|
_QUEUE_SIMPLEQUEUE_QSIZE_METHODDEF
|
||||||
{"__class_getitem__", (PyCFunction)Py_GenericAlias,
|
{"__class_getitem__", Py_GenericAlias,
|
||||||
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
|
@ -2708,7 +2708,7 @@ static PyMethodDef pattern_methods[] = {
|
||||||
_SRE_SRE_PATTERN_SCANNER_METHODDEF
|
_SRE_SRE_PATTERN_SCANNER_METHODDEF
|
||||||
_SRE_SRE_PATTERN___COPY___METHODDEF
|
_SRE_SRE_PATTERN___COPY___METHODDEF
|
||||||
_SRE_SRE_PATTERN___DEEPCOPY___METHODDEF
|
_SRE_SRE_PATTERN___DEEPCOPY___METHODDEF
|
||||||
{"__class_getitem__", (PyCFunction)Py_GenericAlias, METH_O|METH_CLASS,
|
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS,
|
||||||
PyDoc_STR("See PEP 585")},
|
PyDoc_STR("See PEP 585")},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
@ -2764,7 +2764,7 @@ static PyMethodDef match_methods[] = {
|
||||||
_SRE_SRE_MATCH_EXPAND_METHODDEF
|
_SRE_SRE_MATCH_EXPAND_METHODDEF
|
||||||
_SRE_SRE_MATCH___COPY___METHODDEF
|
_SRE_SRE_MATCH___COPY___METHODDEF
|
||||||
_SRE_SRE_MATCH___DEEPCOPY___METHODDEF
|
_SRE_SRE_MATCH___DEEPCOPY___METHODDEF
|
||||||
{"__class_getitem__", (PyCFunction)Py_GenericAlias, METH_O|METH_CLASS,
|
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS,
|
||||||
PyDoc_STR("See PEP 585")},
|
PyDoc_STR("See PEP 585")},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
|
@ -2165,7 +2165,7 @@ static PyMethodDef chain_methods[] = {
|
||||||
reduce_doc},
|
reduce_doc},
|
||||||
{"__setstate__", (PyCFunction)chain_setstate, METH_O,
|
{"__setstate__", (PyCFunction)chain_setstate, METH_O,
|
||||||
setstate_doc},
|
setstate_doc},
|
||||||
{"__class_getitem__", (PyCFunction)Py_GenericAlias,
|
{"__class_getitem__", Py_GenericAlias,
|
||||||
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
|
@ -13779,7 +13779,7 @@ static PyMethodDef DirEntry_methods[] = {
|
||||||
OS_DIRENTRY_STAT_METHODDEF
|
OS_DIRENTRY_STAT_METHODDEF
|
||||||
OS_DIRENTRY_INODE_METHODDEF
|
OS_DIRENTRY_INODE_METHODDEF
|
||||||
OS_DIRENTRY___FSPATH___METHODDEF
|
OS_DIRENTRY___FSPATH___METHODDEF
|
||||||
{"__class_getitem__", (PyCFunction)Py_GenericAlias,
|
{"__class_getitem__", Py_GenericAlias,
|
||||||
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1144,7 +1144,7 @@ static PyMethodDef mappingproxy_methods[] = {
|
||||||
PyDoc_STR("D.items() -> list of D's (key, value) pairs, as 2-tuples")},
|
PyDoc_STR("D.items() -> list of D's (key, value) pairs, as 2-tuples")},
|
||||||
{"copy", (PyCFunction)mappingproxy_copy, METH_NOARGS,
|
{"copy", (PyCFunction)mappingproxy_copy, METH_NOARGS,
|
||||||
PyDoc_STR("D.copy() -> a shallow copy of D")},
|
PyDoc_STR("D.copy() -> a shallow copy of D")},
|
||||||
{"__class_getitem__", (PyCFunction)Py_GenericAlias, METH_O|METH_CLASS,
|
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS,
|
||||||
PyDoc_STR("See PEP 585")},
|
PyDoc_STR("See PEP 585")},
|
||||||
{"__reversed__", (PyCFunction)mappingproxy_reversed, METH_NOARGS,
|
{"__reversed__", (PyCFunction)mappingproxy_reversed, METH_NOARGS,
|
||||||
PyDoc_STR("D.__reversed__() -> reverse iterator")},
|
PyDoc_STR("D.__reversed__() -> reverse iterator")},
|
||||||
|
|
|
@ -3294,7 +3294,7 @@ static PyMethodDef mapp_methods[] = {
|
||||||
{"copy", (PyCFunction)dict_copy, METH_NOARGS,
|
{"copy", (PyCFunction)dict_copy, METH_NOARGS,
|
||||||
copy__doc__},
|
copy__doc__},
|
||||||
DICT___REVERSED___METHODDEF
|
DICT___REVERSED___METHODDEF
|
||||||
{"__class_getitem__", (PyCFunction)Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -213,7 +213,7 @@ PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");
|
||||||
|
|
||||||
static PyMethodDef enum_methods[] = {
|
static PyMethodDef enum_methods[] = {
|
||||||
{"__reduce__", (PyCFunction)enum_reduce, METH_NOARGS, reduce_doc},
|
{"__reduce__", (PyCFunction)enum_reduce, METH_NOARGS, reduce_doc},
|
||||||
{"__class_getitem__", (PyCFunction)Py_GenericAlias,
|
{"__class_getitem__", Py_GenericAlias,
|
||||||
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
|
@ -1499,7 +1499,7 @@ static PyMethodDef async_gen_methods[] = {
|
||||||
{"asend", (PyCFunction)async_gen_asend, METH_O, async_asend_doc},
|
{"asend", (PyCFunction)async_gen_asend, METH_O, async_asend_doc},
|
||||||
{"athrow",(PyCFunction)async_gen_athrow, METH_VARARGS, async_athrow_doc},
|
{"athrow",(PyCFunction)async_gen_athrow, METH_VARARGS, async_athrow_doc},
|
||||||
{"aclose", (PyCFunction)async_gen_aclose, METH_NOARGS, async_aclose_doc},
|
{"aclose", (PyCFunction)async_gen_aclose, METH_NOARGS, async_aclose_doc},
|
||||||
{"__class_getitem__", (PyCFunction)Py_GenericAlias,
|
{"__class_getitem__", Py_GenericAlias,
|
||||||
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
||||||
{NULL, NULL} /* Sentinel */
|
{NULL, NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
|
@ -2843,7 +2843,7 @@ static PyMethodDef list_methods[] = {
|
||||||
LIST_COUNT_METHODDEF
|
LIST_COUNT_METHODDEF
|
||||||
LIST_REVERSE_METHODDEF
|
LIST_REVERSE_METHODDEF
|
||||||
LIST_SORT_METHODDEF
|
LIST_SORT_METHODDEF
|
||||||
{"__class_getitem__", (PyCFunction)Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -2047,7 +2047,7 @@ static PyMethodDef set_methods[] = {
|
||||||
union_doc},
|
union_doc},
|
||||||
{"update", (PyCFunction)set_update, METH_VARARGS,
|
{"update", (PyCFunction)set_update, METH_VARARGS,
|
||||||
update_doc},
|
update_doc},
|
||||||
{"__class_getitem__", (PyCFunction)Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2161,7 +2161,7 @@ static PyMethodDef frozenset_methods[] = {
|
||||||
symmetric_difference_doc},
|
symmetric_difference_doc},
|
||||||
{"union", (PyCFunction)set_union, METH_VARARGS,
|
{"union", (PyCFunction)set_union, METH_VARARGS,
|
||||||
union_doc},
|
union_doc},
|
||||||
{"__class_getitem__", (PyCFunction)Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -887,7 +887,7 @@ static PyMethodDef tuple_methods[] = {
|
||||||
TUPLE___GETNEWARGS___METHODDEF
|
TUPLE___GETNEWARGS___METHODDEF
|
||||||
TUPLE_INDEX_METHODDEF
|
TUPLE_INDEX_METHODDEF
|
||||||
TUPLE_COUNT_METHODDEF
|
TUPLE_COUNT_METHODDEF
|
||||||
{"__class_getitem__", (PyCFunction)Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
||||||
{NULL, NULL} /* sentinel */
|
{NULL, NULL} /* sentinel */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -363,7 +363,7 @@ static PyMemberDef weakref_members[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyMethodDef weakref_methods[] = {
|
static PyMethodDef weakref_methods[] = {
|
||||||
{"__class_getitem__", (PyCFunction)Py_GenericAlias,
|
{"__class_getitem__", Py_GenericAlias,
|
||||||
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
||||||
{NULL} /* Sentinel */
|
{NULL} /* Sentinel */
|
||||||
};
|
};
|
||||||
|
|
|
@ -1049,7 +1049,7 @@ static PyMethodDef PyContextVar_methods[] = {
|
||||||
_CONTEXTVARS_CONTEXTVAR_GET_METHODDEF
|
_CONTEXTVARS_CONTEXTVAR_GET_METHODDEF
|
||||||
_CONTEXTVARS_CONTEXTVAR_SET_METHODDEF
|
_CONTEXTVARS_CONTEXTVAR_SET_METHODDEF
|
||||||
_CONTEXTVARS_CONTEXTVAR_RESET_METHODDEF
|
_CONTEXTVARS_CONTEXTVAR_RESET_METHODDEF
|
||||||
{"__class_getitem__", (PyCFunction)Py_GenericAlias,
|
{"__class_getitem__", Py_GenericAlias,
|
||||||
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
@ -1190,7 +1190,7 @@ static PyGetSetDef PyContextTokenType_getsetlist[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static PyMethodDef PyContextTokenType_methods[] = {
|
static PyMethodDef PyContextTokenType_methods[] = {
|
||||||
{"__class_getitem__", (PyCFunction)Py_GenericAlias,
|
{"__class_getitem__", Py_GenericAlias,
|
||||||
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
|
||||||
{NULL}
|
{NULL}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue