diff options
author | Ethan Smith <ethan@ethanhs.me> | 2020-04-14 23:14:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-14 23:14:15 (GMT) |
commit | d01628e411752ee6849f862cae66a1c69fe512b7 (patch) | |
tree | 4b6fc066cc0dc4c1aa2352896d81c0573e5a9138 /Python | |
parent | 33986465bde2a2188537c4ef6cdb6055e348f31f (diff) | |
download | cpython-d01628e411752ee6849f862cae66a1c69fe512b7.zip cpython-d01628e411752ee6849f862cae66a1c69fe512b7.tar.gz cpython-d01628e411752ee6849f862cae66a1c69fe512b7.tar.bz2 |
bpo-39481: PEP 585 for dataclasses, mailbox, contextvars (GH-19425)
Diffstat (limited to 'Python')
-rw-r--r-- | Python/context.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/Python/context.c b/Python/context.c index 00f25dd..15749e9 100644 --- a/Python/context.c +++ b/Python/context.c @@ -1024,13 +1024,6 @@ _contextvars_ContextVar_reset(PyContextVar *self, PyObject *token) } -static PyObject * -contextvar_cls_getitem(PyObject *self, PyObject *arg) -{ - Py_INCREF(self); - return self; -} - static PyMemberDef PyContextVar_members[] = { {"name", T_OBJECT, offsetof(PyContextVar, var_name), READONLY}, {NULL} @@ -1040,8 +1033,8 @@ static PyMethodDef PyContextVar_methods[] = { _CONTEXTVARS_CONTEXTVAR_GET_METHODDEF _CONTEXTVARS_CONTEXTVAR_SET_METHODDEF _CONTEXTVARS_CONTEXTVAR_RESET_METHODDEF - {"__class_getitem__", contextvar_cls_getitem, - METH_O | METH_CLASS, NULL}, + {"__class_getitem__", (PyCFunction)Py_GenericAlias, + METH_O|METH_CLASS, PyDoc_STR("See PEP 585")}, {NULL, NULL} }; @@ -1180,10 +1173,17 @@ static PyGetSetDef PyContextTokenType_getsetlist[] = { {NULL} }; +static PyMethodDef PyContextTokenType_methods[] = { + {"__class_getitem__", (PyCFunction)Py_GenericAlias, + METH_O|METH_CLASS, PyDoc_STR("See PEP 585")}, + {NULL} +}; + PyTypeObject PyContextToken_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) "Token", sizeof(PyContextToken), + .tp_methods = PyContextTokenType_methods, .tp_getset = PyContextTokenType_getsetlist, .tp_dealloc = (destructor)token_tp_dealloc, .tp_getattro = PyObject_GenericGetAttr, |