summaryrefslogtreecommitdiffstats
path: root/Python/context.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-12-08 12:49:07 (GMT)
committerGitHub <noreply@github.com>2019-12-08 12:49:07 (GMT)
commit960fca1a5887a277fd6031cf4c4b6fb31b08ebf5 (patch)
tree58a3cba812fcbed35e66ca2e3b50ac13ee81b427 /Python/context.c
parent9d3cacd5901f8fbbc4f8b78fc35abad01a0e6546 (diff)
downloadcpython-960fca1a5887a277fd6031cf4c4b6fb31b08ebf5.zip
cpython-960fca1a5887a277fd6031cf4c4b6fb31b08ebf5.tar.gz
cpython-960fca1a5887a277fd6031cf4c4b6fb31b08ebf5.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 (cherry picked from commit 28c91631c24e53713ad0e8a2bbae716373f5e53d) Co-authored-by: AMIR <31338382+amiremohamadi@users.noreply.github.com>
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 f48c376..5c30e47 100644
--- a/Python/context.c
+++ b/Python/context.c
@@ -1010,9 +1010,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[] = {
@@ -1025,7 +1026,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}
};