summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_abc.c3
-rw-r--r--Modules/_datetimemodule.c12
-rw-r--r--Modules/_elementtree.c3
-rw-r--r--Modules/_io/_iomodule.c3
-rw-r--r--Modules/_pickle.c3
-rw-r--r--Modules/_scproxy.c2
-rw-r--r--Modules/_struct.c3
-rw-r--r--Modules/_tkinter.c3
-rw-r--r--Modules/_xxsubinterpretersmodule.c3
-rw-r--r--Modules/_zoneinfo.c3
-rw-r--r--Modules/cjkcodecs/multibytecodec.c3
-rw-r--r--Modules/mathmodule.c9
-rw-r--r--Modules/nismodule.c3
-rw-r--r--Modules/posixmodule.c12
14 files changed, 22 insertions, 43 deletions
diff --git a/Modules/_abc.c b/Modules/_abc.c
index e6e7242..e146d4f 100644
--- a/Modules/_abc.c
+++ b/Modules/_abc.c
@@ -624,8 +624,7 @@ _abc__abc_instancecheck_impl(PyObject *module, PyObject *self,
switch (PyObject_IsTrue(result)) {
case -1:
- Py_DECREF(result);
- result = NULL;
+ Py_SETREF(result, NULL);
break;
case 0:
Py_DECREF(result);
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index 712abc3..eda8c56 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -1328,8 +1328,7 @@ call_tzname(PyObject *tzinfo, PyObject *tzinfoarg)
PyErr_Format(PyExc_TypeError, "tzinfo.tzname() must "
"return None or a string, not '%s'",
Py_TYPE(result)->tp_name);
- Py_DECREF(result);
- result = NULL;
+ Py_SETREF(result, NULL);
}
return result;
@@ -1849,8 +1848,7 @@ delta_to_microseconds(PyDateTime_Delta *self)
x2 = PyNumber_Multiply(x1, seconds_per_day); /* days in seconds */
if (x2 == NULL)
goto Done;
- Py_DECREF(x1);
- x1 = NULL;
+ Py_SETREF(x1, NULL);
/* x2 has days in seconds */
x1 = PyLong_FromLong(GET_TD_SECONDS(self)); /* seconds */
@@ -1867,8 +1865,7 @@ delta_to_microseconds(PyDateTime_Delta *self)
x1 = PyNumber_Multiply(x3, us_per_second); /* us */
if (x1 == NULL)
goto Done;
- Py_DECREF(x3);
- x3 = NULL;
+ Py_SETREF(x3, NULL);
/* x1 has days+seconds in us */
x2 = PyLong_FromLong(GET_TD_MICROSECONDS(self));
@@ -2038,8 +2035,7 @@ multiply_truedivide_timedelta_float(PyDateTime_Delta *delta, PyObject *floatobj,
goto error;
}
temp = PyNumber_Multiply(pyus_in, PyTuple_GET_ITEM(ratio, op));
- Py_DECREF(pyus_in);
- pyus_in = NULL;
+ Py_SETREF(pyus_in, NULL);
if (temp == NULL)
goto error;
pyus_out = divide_nearest(temp, PyTuple_GET_ITEM(ratio, !op));
diff --git a/Modules/_elementtree.c b/Modules/_elementtree.c
index 2da44cf..0c68ede 100644
--- a/Modules/_elementtree.c
+++ b/Modules/_elementtree.c
@@ -345,8 +345,7 @@ get_attrib_from_keywords(PyObject *kwds)
}
attrib = PyDict_Copy(attrib);
if (attrib && PyDict_DelItem(kwds, attrib_str) < 0) {
- Py_DECREF(attrib);
- attrib = NULL;
+ Py_SETREF(attrib, NULL);
}
}
else if (!PyErr_Occurred()) {
diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c
index ccd40ab..121d961 100644
--- a/Modules/_io/_iomodule.c
+++ b/Modules/_io/_iomodule.c
@@ -334,8 +334,7 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode,
goto error;
result = raw;
- Py_DECREF(path_or_fd);
- path_or_fd = NULL;
+ Py_SETREF(path_or_fd, NULL);
modeobj = PyUnicode_FromString(mode);
if (modeobj == NULL)
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index 1e118e9..2078779 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -4344,8 +4344,7 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
if (reduce_value != Py_NotImplemented) {
goto reduce;
}
- Py_DECREF(reduce_value);
- reduce_value = NULL;
+ Py_SETREF(reduce_value, NULL);
}
if (type == &PyType_Type) {
diff --git a/Modules/_scproxy.c b/Modules/_scproxy.c
index 4c1f1aa..344b66f 100644
--- a/Modules/_scproxy.c
+++ b/Modules/_scproxy.c
@@ -84,7 +84,7 @@ get_proxy_settings(PyObject* Py_UNUSED(mod), PyObject *Py_UNUSED(ignored))
if (v == NULL) goto error;
r = PyDict_SetItemString(result, "exclude_simple", v);
- Py_DECREF(v); v = NULL;
+ Py_SETREF(v, NULL);
if (r == -1) goto error;
anArray = CFDictionaryGetValue(proxyDict,
diff --git a/Modules/_struct.c b/Modules/_struct.c
index 2f2eb25..c960b81 100644
--- a/Modules/_struct.c
+++ b/Modules/_struct.c
@@ -2164,8 +2164,7 @@ cache_struct_converter(PyObject *module, PyObject *fmt, PyStructObject **ptr)
_structmodulestate *state = get_struct_state(module);
if (fmt == NULL) {
- Py_DECREF(*ptr);
- *ptr = NULL;
+ Py_SETREF(*ptr, NULL);
return 1;
}
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index 6ff7d2b..93d4474 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -2163,8 +2163,7 @@ _tkinter_tkapp_splitlist(TkappObject *self, PyObject *arg)
for (i = 0; i < argc; i++) {
PyObject *s = unicodeFromTclString(argv[i]);
if (!s) {
- Py_DECREF(v);
- v = NULL;
+ Py_SETREF(v, NULL);
goto finally;
}
PyTuple_SET_ITEM(v, i, s);
diff --git a/Modules/_xxsubinterpretersmodule.c b/Modules/_xxsubinterpretersmodule.c
index 244ae35..2c9e0cd 100644
--- a/Modules/_xxsubinterpretersmodule.c
+++ b/Modules/_xxsubinterpretersmodule.c
@@ -2320,8 +2320,7 @@ channel_list_all(PyObject *self, PyObject *Py_UNUSED(ignored))
PyObject *id = (PyObject *)newchannelid(&ChannelIDtype, *cur, 0,
&_globals.channels, 0, 0);
if (id == NULL) {
- Py_DECREF(ids);
- ids = NULL;
+ Py_SETREF(ids, NULL);
break;
}
PyList_SET_ITEM(ids, (Py_ssize_t)i, id);
diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c
index cb7d4c9..9d38589 100644
--- a/Modules/_zoneinfo.c
+++ b/Modules/_zoneinfo.c
@@ -220,8 +220,7 @@ zoneinfo_new_instance(PyTypeObject *type, PyObject *key)
}
PyObject *rv = PyObject_CallMethod(file_obj, "close", NULL);
- Py_DECREF(file_obj);
- file_obj = NULL;
+ Py_SETREF(file_obj, NULL);
if (rv == NULL) {
goto error;
}
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c
index 8b62326..1d77fd3 100644
--- a/Modules/cjkcodecs/multibytecodec.c
+++ b/Modules/cjkcodecs/multibytecodec.c
@@ -1463,8 +1463,7 @@ mbstreamreader_iread(MultibyteStreamReaderObject *self,
goto errorexit;
}
- Py_DECREF(cres);
- cres = NULL;
+ Py_SETREF(cres, NULL);
if (sizehint < 0 || buf.writer.pos != 0 || rsize == 0)
break;
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c
index 83eb338..49c0293 100644
--- a/Modules/mathmodule.c
+++ b/Modules/mathmodule.c
@@ -3152,8 +3152,7 @@ math_prod_impl(PyObject *module, PyObject *iterable, PyObject *start)
long i_result = PyLong_AsLongAndOverflow(result, &overflow);
/* If this already overflowed, don't even enter the loop. */
if (overflow == 0) {
- Py_DECREF(result);
- result = NULL;
+ Py_SETREF(result, NULL);
}
/* Loop over all the items in the iterable until we finish, we overflow
* or we found a non integer element */
@@ -3200,8 +3199,7 @@ math_prod_impl(PyObject *module, PyObject *iterable, PyObject *start)
*/
if (PyFloat_CheckExact(result)) {
double f_result = PyFloat_AS_DOUBLE(result);
- Py_DECREF(result);
- result = NULL;
+ Py_SETREF(result, NULL);
while(result == NULL) {
item = PyIter_Next(iter);
if (item == NULL) {
@@ -3250,8 +3248,7 @@ math_prod_impl(PyObject *module, PyObject *iterable, PyObject *start)
if (item == NULL) {
/* error, or end-of-sequence */
if (PyErr_Occurred()) {
- Py_DECREF(result);
- result = NULL;
+ Py_SETREF(result, NULL);
}
break;
}
diff --git a/Modules/nismodule.c b/Modules/nismodule.c
index 39b9911..ec7f6d8 100644
--- a/Modules/nismodule.c
+++ b/Modules/nismodule.c
@@ -458,8 +458,7 @@ nis_maps (PyObject *module, PyObject *args, PyObject *kwdict)
if (!str || PyList_Append(list, str) < 0)
{
Py_XDECREF(str);
- Py_DECREF(list);
- list = NULL;
+ Py_SETREF(list, NULL);
break;
}
Py_DECREF(str);
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 45e71ee..8185517 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -4036,14 +4036,12 @@ _listdir_windows_no_opendir(path_t *path, PyObject *list)
Py_SETREF(v, PyUnicode_EncodeFSDefault(v));
}
if (v == NULL) {
- Py_DECREF(list);
- list = NULL;
+ Py_SETREF(list, NULL);
break;
}
if (PyList_Append(list, v) != 0) {
Py_DECREF(v);
- Py_DECREF(list);
- list = NULL;
+ Py_SETREF(list, NULL);
break;
}
Py_DECREF(v);
@@ -13131,15 +13129,13 @@ os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks)
PyObject *attribute = PyUnicode_DecodeFSDefaultAndSize(start,
trace - start);
if (!attribute) {
- Py_DECREF(result);
- result = NULL;
+ Py_SETREF(result, NULL);
goto exit;
}
error = PyList_Append(result, attribute);
Py_DECREF(attribute);
if (error) {
- Py_DECREF(result);
- result = NULL;
+ Py_SETREF(result, NULL);
goto exit;
}
start = trace + 1;