bpo-33985: Implement ContextVar.name attribute. (GH-7980)

(cherry picked from commit 41cb0baea9)

Co-authored-by: Yury Selivanov <yury@magic.io>
This commit is contained in:
Miss Islington (bot) 2018-06-28 10:39:54 -07:00 committed by GitHub
parent 48dc7527e3
commit 4c20d2bf5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 2 deletions

View file

@ -940,6 +940,10 @@ contextvar_cls_getitem(PyObject *self, PyObject *args)
Py_RETURN_NONE;
}
static PyMemberDef PyContextVar_members[] = {
{"name", T_OBJECT, offsetof(PyContextVar, var_name), READONLY},
{NULL}
};
static PyMethodDef PyContextVar_methods[] = {
_CONTEXTVARS_CONTEXTVAR_GET_METHODDEF
@ -955,6 +959,7 @@ PyTypeObject PyContextVar_Type = {
"ContextVar",
sizeof(PyContextVar),
.tp_methods = PyContextVar_methods,
.tp_members = PyContextVar_members,
.tp_dealloc = (destructor)contextvar_tp_dealloc,
.tp_getattro = PyObject_GenericGetAttr,
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,