diff options
author | AMIR <31338382+amiremohamadi@users.noreply.github.com> | 2019-12-08 11:35:59 (GMT) |
---|---|---|
committer | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2019-12-08 11:35:59 (GMT) |
commit | 28c91631c24e53713ad0e8a2bbae716373f5e53d (patch) | |
tree | a870b24a5128a4424e85cd2e4ad6693417e1c0c4 /Python/context.c | |
parent | 00ada2c1d57c5b8b468bad32ff24fa14113ae5c7 (diff) | |
download | cpython-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.c | 7 |
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} }; |