Replace "Py_XDECREF(var); var = NULL;" with "Py_CLEAR(var);".
Don't replace "Py_DECREF(var); var = NULL;" with "Py_CLEAR(var);". It
would add an useless "if (var)" test in code path where var cannot be
NULL.
goto finally;
except:
- Py_XDECREF(ids);
- ids = NULL;
+ Py_CLEAR(ids);
finally:
return ids;
goto cleanup;
error:
- Py_XDECREF(self);
- self = NULL;
+ Py_CLEAR(self);
cleanup:
if (file_obj != NULL) {
PyObject *exc, *val, *tb;
static void
module_free(void *m)
{
- Py_XDECREF(_tzpath_find_tzfile);
- _tzpath_find_tzfile = NULL;
-
- Py_XDECREF(_common_mod);
- _common_mod = NULL;
-
- Py_XDECREF(io_open);
- io_open = NULL;
+ Py_CLEAR(_tzpath_find_tzfile);
+ Py_CLEAR(_common_mod);
+ Py_CLEAR(io_open);
xdecref_ttinfo(&NO_TTINFO);