FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-132457: make staticmethod and classmethod generic by IvanKirpichnikov · Pull Request #132460 · python/cpython · GitHub

/ cpython Public
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .py  (1) .rst  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 3 additions & 1 deletion Lib/test/test_genericalias.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL