Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Lib/test/test_genericalias.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ class BaseTest(unittest.TestCase):
Future, _WorkItem,
Morsel,
DictReader, DictWriter,
array]
array,
staticmethod,
classmethod]
if ctypes is not None:
generic_types.extend((ctypes.Array, ctypes.LibraryLoader, ctypes.py_object))
if ValueProxy is not None:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Make :func:`staticmethod` and :func:`classmethod` generic.
14 changes: 12 additions & 2 deletions Objects/funcobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,11 @@ static PyGetSetDef cm_getsetlist[] = {
{NULL} /* Sentinel */
};

static PyMethodDef cm_methodlist[] = {
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, NULL},
{NULL} /* Sentinel */
};

static PyObject*
cm_repr(PyObject *self)
{
Expand Down Expand Up @@ -1542,7 +1547,7 @@ PyTypeObject PyClassMethod_Type = {
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
cm_methodlist, /* tp_methods */
cm_memberlist, /* tp_members */
cm_getsetlist, /* tp_getset */
0, /* tp_base */
Expand Down Expand Up @@ -1716,6 +1721,11 @@ static PyGetSetDef sm_getsetlist[] = {
{NULL} /* Sentinel */
};

static PyMethodDef sm_methodlist[] = {
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, NULL},
{NULL} /* Sentinel */
};

static PyObject*
sm_repr(PyObject *self)
{
Expand Down Expand Up @@ -1772,7 +1782,7 @@ PyTypeObject PyStaticMethod_Type = {
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
0, /* tp_methods */
sm_methodlist, /* tp_methods */
sm_memberlist, /* tp_members */
sm_getsetlist, /* tp_getset */
0, /* tp_base */
Expand Down
Loading