@@ -1024,13 +1024,6 @@ _contextvars_ContextVar_reset(PyContextVar *self, PyObject *token)
10241024}
10251025
10261026
1027- static PyObject *
1028- contextvar_cls_getitem (PyObject * self , PyObject * arg )
1029- {
1030- Py_INCREF (self );
1031- return self ;
1032- }
1033-
10341027static PyMemberDef PyContextVar_members [] = {
10351028 {"name" , T_OBJECT , offsetof(PyContextVar , var_name ), READONLY },
10361029 {NULL }
@@ -1040,8 +1033,8 @@ static PyMethodDef PyContextVar_methods[] = {
10401033 _CONTEXTVARS_CONTEXTVAR_GET_METHODDEF
10411034 _CONTEXTVARS_CONTEXTVAR_SET_METHODDEF
10421035 _CONTEXTVARS_CONTEXTVAR_RESET_METHODDEF
1043- {"__class_getitem__" , contextvar_cls_getitem ,
1044- METH_O | METH_CLASS , NULL },
1036+ {"__class_getitem__" , ( PyCFunction ) Py_GenericAlias ,
1037+ METH_O | METH_CLASS , PyDoc_STR ( "See PEP 585" ) },
10451038 {NULL , NULL }
10461039};
10471040
@@ -1180,10 +1173,17 @@ static PyGetSetDef PyContextTokenType_getsetlist[] = {
11801173 {NULL }
11811174};
11821175
1176+ static PyMethodDef PyContextTokenType_methods [] = {
1177+ {"__class_getitem__" , (PyCFunction )Py_GenericAlias ,
1178+ METH_O |METH_CLASS , PyDoc_STR ("See PEP 585" )},
1179+ {NULL }
1180+ };
1181+
11831182PyTypeObject PyContextToken_Type = {
11841183 PyVarObject_HEAD_INIT (& PyType_Type , 0 )
11851184 "Token" ,
11861185 sizeof (PyContextToken ),
1186+ .tp_methods = PyContextTokenType_methods ,
11871187 .tp_getset = PyContextTokenType_getsetlist ,
11881188 .tp_dealloc = (destructor )token_tp_dealloc ,
11891189 .tp_getattro = PyObject_GenericGetAttr ,
0 commit comments