Skip to content
Prev Previous commit
Next Next commit
Use Py_CLEAR rather than Py_XDECREF
  • Loading branch information
encukou committed Nov 13, 2020
commit 23f844ad71e4b3084b6d3510c220a740b52044ea
38 changes: 19 additions & 19 deletions Modules/_csv.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,15 @@ static void
Dialect_dealloc(DialectObj *self)
{
PyTypeObject *tp = Py_TYPE(self);
Py_XDECREF(self->lineterminator);
Py_CLEAR(self->lineterminator);
tp->tp_free((PyObject *)self);
Py_DECREF(tp);
}

static void
Dialect_finalize(DialectObj *self)
{
Py_XDECREF(self->lineterminator);
Py_CLEAR(self->lineterminator);
}

static char *dialect_kws[] = {
Expand Down Expand Up @@ -402,7 +402,7 @@ dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)

self = (DialectObj *)type->tp_alloc(type, 0);
if (self == NULL) {
Py_XDECREF(dialect);
Py_CLEAR(dialect);
Comment thread
encukou marked this conversation as resolved.
return NULL;
}
self->lineterminator = NULL;
Expand Down Expand Up @@ -466,16 +466,16 @@ dialect_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
ret = (PyObject *)self;
Py_INCREF(self);
err:
Py_XDECREF(self);
Py_XDECREF(dialect);
Py_XDECREF(delimiter);
Py_XDECREF(doublequote);
Py_XDECREF(escapechar);
Py_XDECREF(lineterminator);
Py_XDECREF(quotechar);
Py_XDECREF(quoting);
Py_XDECREF(skipinitialspace);
Py_XDECREF(strict);
Py_CLEAR(self);
Py_CLEAR(dialect);
Py_CLEAR(delimiter);
Py_CLEAR(doublequote);
Py_CLEAR(escapechar);
Py_CLEAR(lineterminator);
Py_CLEAR(quotechar);
Py_CLEAR(quoting);
Py_CLEAR(skipinitialspace);
Py_CLEAR(strict);
return ret;
}

Expand Down Expand Up @@ -885,9 +885,9 @@ Reader_dealloc(ReaderObj *self)
{
PyTypeObject *tp = Py_TYPE(self);
PyObject_GC_UnTrack(self);
Py_XDECREF(self->dialect);
Py_XDECREF(self->input_iter);
Py_XDECREF(self->fields);
Py_CLEAR(self->dialect);
Py_CLEAR(self->input_iter);
Py_CLEAR(self->fields);
if (self->field != NULL)
PyMem_Free(self->field);
PyObject_GC_Del(self);
Expand All @@ -897,9 +897,9 @@ Reader_dealloc(ReaderObj *self)
static void
Reader_finalize(ReaderObj *self)
{
Py_XDECREF(self->dialect);
Py_XDECREF(self->input_iter);
Py_XDECREF(self->fields);
Py_CLEAR(self->dialect);
Py_CLEAR(self->input_iter);
Py_CLEAR(self->fields);
if (self->field != NULL) {
PyMem_Free(self->field);
Comment thread
encukou marked this conversation as resolved.
}
Expand Down