# HG changeset patch # User Siddharth Agarwal # Date 2015-04-08 03:43:04 # Node ID 67241ee427cfb457d7728e44fc772572c1555c2e # Parent b83a8f512a80403721d56343f2d22a10ba655241 dirs._addpath: reinstate use of Py_CLEAR I changed this to an explicit Py_DECREF + set to null in 6f0e6fa9fdd7. This was a silly misunderstanding on my part -- for some reason I thought Py_CLEAR set its argument to null only if its refcount reached 0. Turns out that's not actually the case -- Py_CLEAR is just Py_DECREF + set to null with some additional precautions around destructors that aren't relevant here. The real bug that 6f0e6fa9fdd7 fixed was the fact that we were mutating the string after setting it in the Python dictionary. diff --git a/mercurial/dirs.c b/mercurial/dirs.c --- a/mercurial/dirs.c +++ b/mercurial/dirs.c @@ -94,10 +94,8 @@ static int _addpath(PyObject *dirs, PyOb goto bail; /* Clear the key out since we've already exposed it to Python - and can't mutate it further. key's refcount is currently 2 so - we can't just use Py_CLEAR. */ - Py_DECREF(key); - key = NULL; + and can't mutate it further. */ + Py_CLEAR(key); } ret = 0;