Skip to content

Commit 6ab6292

Browse files
authored
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.
1 parent b31206a commit 6ab6292

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Python/context.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ PyContextVar_New(const char *name, PyObject *def)
134134
if (pyname == NULL) {
135135
return NULL;
136136
}
137-
return contextvar_new(pyname, def);
137+
PyContextVar *var = contextvar_new(pyname, def);
138+
Py_DECREF(pyname);
139+
return var;
138140
}
139141

140142

@@ -741,8 +743,8 @@ contextvar_new(PyObject *name, PyObject *def)
741743
var->var_cached_tsid = 0;
742744
var->var_cached_tsver = 0;
743745

744-
if (_PyObject_GC_IS_TRACKED(name) ||
745-
(def != NULL && _PyObject_GC_IS_TRACKED(def)))
746+
if (_PyObject_GC_MAY_BE_TRACKED(name) ||
747+
(def != NULL && _PyObject_GC_MAY_BE_TRACKED(def)))
746748
{
747749
PyObject_GC_Track(var);
748750
}

Python/hamt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ hamt_bitcount(uint32_t i)
449449
*/
450450
i = i - ((i >> 1) & 0x55555555);
451451
i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
452-
return ((i + (i >> 4) & 0xF0F0F0F) * 0x1010101) >> 24;
452+
return (((i + (i >> 4)) & 0xF0F0F0F) * 0x1010101) >> 24;
453453
}
454454

455455
static inline uint32_t

0 commit comments

Comments
 (0)