summaryrefslogtreecommitdiffstats
path: root/Python/context.c
diff options
context:
space:
mode:
authorAMIR <31338382+amiremohamadi@users.noreply.github.com>2019-12-08 11:35:59 (GMT)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-12-08 11:35:59 (GMT)
commit28c91631c24e53713ad0e8a2bbae716373f5e53d (patch)
treea870b24a5128a4424e85cd2e4ad6693417e1c0c4 /Python/context.c
parent00ada2c1d57c5b8b468bad32ff24fa14113ae5c7 (diff)
downloadcpython-28c91631c24e53713ad0e8a2bbae716373f5e53d.zip
cpython-28c91631c24e53713ad0e8a2bbae716373f5e53d.tar.gz
cpython-28c91631c24e53713ad0e8a2bbae716373f5e53d.tar.bz2
bpo-38979: fix ContextVar "__class_getitem__" method (GH-17497)
now contextvars.ContextVar "__class_getitem__" method returns ContextVar class, not None. https://bugs.python.org/issue38979 Automerge-Triggered-By: @asvetlov
Diffstat (limited to 'Python/context.c')
-rw-r--r--Python/context.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Python/context.c b/Python/context.c
index 26f2299..e0338c9 100644
--- a/Python/context.c
+++ b/Python/context.c
@@ -1024,9 +1024,10 @@ _contextvars_ContextVar_reset(PyContextVar *self, PyObject *token)
static PyObject *
-contextvar_cls_getitem(PyObject *self, PyObject *args)
+contextvar_cls_getitem(PyObject *self, PyObject *arg)
{
- Py_RETURN_NONE;
+ Py_INCREF(self);
+ return self;
}
static PyMemberDef PyContextVar_members[] = {
@@ -1039,7 +1040,7 @@ static PyMethodDef PyContextVar_methods[] = {
_CONTEXTVARS_CONTEXTVAR_SET_METHODDEF
_CONTEXTVARS_CONTEXTVAR_RESET_METHODDEF
{"__class_getitem__", contextvar_cls_getitem,
- METH_VARARGS | METH_STATIC, NULL},
+ METH_O | METH_CLASS, NULL},
{NULL, NULL}
};