Am 12.09.2012 17:42, schrieb Stefan Krah: > I think 'k' is owned by the PySTEntryObject after it is assigned here: >> ste->ste_id = k; >>> So ste_dealloc() will call Py_XDECREF(k) a second time. You are right. I missed that ste steals the reference to k and does its own cleanup. I've fixed the issue and moved Py_DECREF(k) into ste == NULL block. http://hg.python.org/cpython/rev/2888356cdd4e http://hg.python.org/cpython/rev/99ab7006e466 Thanks!