diff options
author | Yury Selivanov <yury@magic.io> | 2018-01-25 19:18:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-25 19:18:55 (GMT) |
commit | 6ab62920c87930dedc31fe633ecda3e51d3d7503 (patch) | |
tree | 41524fb4f9cf00dcbbb747780c952535113478d9 /Python/context.c | |
parent | b31206a223955d614d7769f95fb979d60f77bf87 (diff) | |
download | cpython-6ab62920c87930dedc31fe633ecda3e51d3d7503.zip cpython-6ab62920c87930dedc31fe633ecda3e51d3d7503.tar.gz cpython-6ab62920c87930dedc31fe633ecda3e51d3d7503.tar.bz2 |
bpo-32436: Fix a refleak; var GC tracking; a GCC warning (#5326)
The refleak in question wasn't really important, as context vars
are usually created at the toplevel and live as long as the interpreter
lives, so the context var name isn't ever GCed anyways.
Diffstat (limited to 'Python/context.c')
-rw-r--r-- | Python/context.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Python/context.c b/Python/context.c index 5439531..d90ed25 100644 --- a/Python/context.c +++ b/Python/context.c @@ -134,7 +134,9 @@ PyContextVar_New(const char *name, PyObject *def) if (pyname == NULL) { return NULL; } - return contextvar_new(pyname, def); + PyContextVar *var = contextvar_new(pyname, def); + Py_DECREF(pyname); + return var; } @@ -741,8 +743,8 @@ contextvar_new(PyObject *name, PyObject *def) var->var_cached_tsid = 0; var->var_cached_tsver = 0; - if (_PyObject_GC_IS_TRACKED(name) || - (def != NULL && _PyObject_GC_IS_TRACKED(def))) + if (_PyObject_GC_MAY_BE_TRACKED(name) || + (def != NULL && _PyObject_GC_MAY_BE_TRACKED(def))) { PyObject_GC_Track(var); } |