bpo-39481: PEP 585 for dataclasses, mailbox, contextvars (GH-19425) · python/cpython@d01628e (original) (raw)
`@@ -1024,13 +1024,6 @@ _contextvars_ContextVar_reset(PyContextVar *self, PyObject *token)
`
1024
1024
`}
`
1025
1025
``
1026
1026
``
1027
``
`-
static PyObject *
`
1028
``
`-
contextvar_cls_getitem(PyObject *self, PyObject *arg)
`
1029
``
`-
{
`
1030
``
`-
Py_INCREF(self);
`
1031
``
`-
return self;
`
1032
``
`-
}
`
1033
``
-
1034
1027
`static PyMemberDef PyContextVar_members[] = {
`
1035
1028
` {"name", T_OBJECT, offsetof(PyContextVar, var_name), READONLY},
`
1036
1029
` {NULL}
`
`@@ -1040,8 +1033,8 @@ static PyMethodDef PyContextVar_methods[] = {
`
1040
1033
`_CONTEXTVARS_CONTEXTVAR_GET_METHODDEF
`
1041
1034
`_CONTEXTVARS_CONTEXTVAR_SET_METHODDEF
`
1042
1035
`_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")},
`
1045
1038
` {NULL, NULL}
`
1046
1039
`};
`
1047
1040
``
`@@ -1180,10 +1173,17 @@ static PyGetSetDef PyContextTokenType_getsetlist[] = {
`
1180
1173
` {NULL}
`
1181
1174
`};
`
1182
1175
``
``
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
+
1183
1182
`PyTypeObject PyContextToken_Type = {
`
1184
1183
`PyVarObject_HEAD_INIT(&PyType_Type, 0)
`
1185
1184
`"Token",
`
1186
1185
`sizeof(PyContextToken),
`
``
1186
`+
.tp_methods = PyContextTokenType_methods,
`
1187
1187
` .tp_getset = PyContextTokenType_getsetlist,
`
1188
1188
` .tp_dealloc = (destructor)token_tp_dealloc,
`
1189
1189
` .tp_getattro = PyObject_GenericGetAttr,
`