mirror of https://github.com/python/cpython
gh-99537: Use Py_SETREF(var, NULL) in C code (#99687)
Replace "Py_DECREF(var); var = NULL;" with "Py_SETREF(var, NULL);".
This commit is contained in:
parent
5d9183c7ad
commit
81f7359f67
|
@ -624,8 +624,7 @@ _abc__abc_instancecheck_impl(PyObject *module, PyObject *self,
|
||||||
|
|
||||||
switch (PyObject_IsTrue(result)) {
|
switch (PyObject_IsTrue(result)) {
|
||||||
case -1:
|
case -1:
|
||||||
Py_DECREF(result);
|
Py_SETREF(result, NULL);
|
||||||
result = NULL;
|
|
||||||
break;
|
break;
|
||||||
case 0:
|
case 0:
|
||||||
Py_DECREF(result);
|
Py_DECREF(result);
|
||||||
|
|
|
@ -1328,8 +1328,7 @@ call_tzname(PyObject *tzinfo, PyObject *tzinfoarg)
|
||||||
PyErr_Format(PyExc_TypeError, "tzinfo.tzname() must "
|
PyErr_Format(PyExc_TypeError, "tzinfo.tzname() must "
|
||||||
"return None or a string, not '%s'",
|
"return None or a string, not '%s'",
|
||||||
Py_TYPE(result)->tp_name);
|
Py_TYPE(result)->tp_name);
|
||||||
Py_DECREF(result);
|
Py_SETREF(result, NULL);
|
||||||
result = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -1849,8 +1848,7 @@ delta_to_microseconds(PyDateTime_Delta *self)
|
||||||
x2 = PyNumber_Multiply(x1, seconds_per_day); /* days in seconds */
|
x2 = PyNumber_Multiply(x1, seconds_per_day); /* days in seconds */
|
||||||
if (x2 == NULL)
|
if (x2 == NULL)
|
||||||
goto Done;
|
goto Done;
|
||||||
Py_DECREF(x1);
|
Py_SETREF(x1, NULL);
|
||||||
x1 = NULL;
|
|
||||||
|
|
||||||
/* x2 has days in seconds */
|
/* x2 has days in seconds */
|
||||||
x1 = PyLong_FromLong(GET_TD_SECONDS(self)); /* 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 */
|
x1 = PyNumber_Multiply(x3, us_per_second); /* us */
|
||||||
if (x1 == NULL)
|
if (x1 == NULL)
|
||||||
goto Done;
|
goto Done;
|
||||||
Py_DECREF(x3);
|
Py_SETREF(x3, NULL);
|
||||||
x3 = NULL;
|
|
||||||
|
|
||||||
/* x1 has days+seconds in us */
|
/* x1 has days+seconds in us */
|
||||||
x2 = PyLong_FromLong(GET_TD_MICROSECONDS(self));
|
x2 = PyLong_FromLong(GET_TD_MICROSECONDS(self));
|
||||||
|
@ -2038,8 +2035,7 @@ multiply_truedivide_timedelta_float(PyDateTime_Delta *delta, PyObject *floatobj,
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
temp = PyNumber_Multiply(pyus_in, PyTuple_GET_ITEM(ratio, op));
|
temp = PyNumber_Multiply(pyus_in, PyTuple_GET_ITEM(ratio, op));
|
||||||
Py_DECREF(pyus_in);
|
Py_SETREF(pyus_in, NULL);
|
||||||
pyus_in = NULL;
|
|
||||||
if (temp == NULL)
|
if (temp == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
pyus_out = divide_nearest(temp, PyTuple_GET_ITEM(ratio, !op));
|
pyus_out = divide_nearest(temp, PyTuple_GET_ITEM(ratio, !op));
|
||||||
|
|
|
@ -345,8 +345,7 @@ get_attrib_from_keywords(PyObject *kwds)
|
||||||
}
|
}
|
||||||
attrib = PyDict_Copy(attrib);
|
attrib = PyDict_Copy(attrib);
|
||||||
if (attrib && PyDict_DelItem(kwds, attrib_str) < 0) {
|
if (attrib && PyDict_DelItem(kwds, attrib_str) < 0) {
|
||||||
Py_DECREF(attrib);
|
Py_SETREF(attrib, NULL);
|
||||||
attrib = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!PyErr_Occurred()) {
|
else if (!PyErr_Occurred()) {
|
||||||
|
|
|
@ -334,8 +334,7 @@ _io_open_impl(PyObject *module, PyObject *file, const char *mode,
|
||||||
goto error;
|
goto error;
|
||||||
result = raw;
|
result = raw;
|
||||||
|
|
||||||
Py_DECREF(path_or_fd);
|
Py_SETREF(path_or_fd, NULL);
|
||||||
path_or_fd = NULL;
|
|
||||||
|
|
||||||
modeobj = PyUnicode_FromString(mode);
|
modeobj = PyUnicode_FromString(mode);
|
||||||
if (modeobj == NULL)
|
if (modeobj == NULL)
|
||||||
|
|
|
@ -4344,8 +4344,7 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
|
||||||
if (reduce_value != Py_NotImplemented) {
|
if (reduce_value != Py_NotImplemented) {
|
||||||
goto reduce;
|
goto reduce;
|
||||||
}
|
}
|
||||||
Py_DECREF(reduce_value);
|
Py_SETREF(reduce_value, NULL);
|
||||||
reduce_value = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == &PyType_Type) {
|
if (type == &PyType_Type) {
|
||||||
|
|
|
@ -84,7 +84,7 @@ get_proxy_settings(PyObject* Py_UNUSED(mod), PyObject *Py_UNUSED(ignored))
|
||||||
if (v == NULL) goto error;
|
if (v == NULL) goto error;
|
||||||
|
|
||||||
r = PyDict_SetItemString(result, "exclude_simple", v);
|
r = PyDict_SetItemString(result, "exclude_simple", v);
|
||||||
Py_DECREF(v); v = NULL;
|
Py_SETREF(v, NULL);
|
||||||
if (r == -1) goto error;
|
if (r == -1) goto error;
|
||||||
|
|
||||||
anArray = CFDictionaryGetValue(proxyDict,
|
anArray = CFDictionaryGetValue(proxyDict,
|
||||||
|
|
|
@ -2164,8 +2164,7 @@ cache_struct_converter(PyObject *module, PyObject *fmt, PyStructObject **ptr)
|
||||||
_structmodulestate *state = get_struct_state(module);
|
_structmodulestate *state = get_struct_state(module);
|
||||||
|
|
||||||
if (fmt == NULL) {
|
if (fmt == NULL) {
|
||||||
Py_DECREF(*ptr);
|
Py_SETREF(*ptr, NULL);
|
||||||
*ptr = NULL;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2163,8 +2163,7 @@ _tkinter_tkapp_splitlist(TkappObject *self, PyObject *arg)
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
PyObject *s = unicodeFromTclString(argv[i]);
|
PyObject *s = unicodeFromTclString(argv[i]);
|
||||||
if (!s) {
|
if (!s) {
|
||||||
Py_DECREF(v);
|
Py_SETREF(v, NULL);
|
||||||
v = NULL;
|
|
||||||
goto finally;
|
goto finally;
|
||||||
}
|
}
|
||||||
PyTuple_SET_ITEM(v, i, s);
|
PyTuple_SET_ITEM(v, i, s);
|
||||||
|
|
|
@ -2320,8 +2320,7 @@ channel_list_all(PyObject *self, PyObject *Py_UNUSED(ignored))
|
||||||
PyObject *id = (PyObject *)newchannelid(&ChannelIDtype, *cur, 0,
|
PyObject *id = (PyObject *)newchannelid(&ChannelIDtype, *cur, 0,
|
||||||
&_globals.channels, 0, 0);
|
&_globals.channels, 0, 0);
|
||||||
if (id == NULL) {
|
if (id == NULL) {
|
||||||
Py_DECREF(ids);
|
Py_SETREF(ids, NULL);
|
||||||
ids = NULL;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PyList_SET_ITEM(ids, (Py_ssize_t)i, id);
|
PyList_SET_ITEM(ids, (Py_ssize_t)i, id);
|
||||||
|
|
|
@ -220,8 +220,7 @@ zoneinfo_new_instance(PyTypeObject *type, PyObject *key)
|
||||||
}
|
}
|
||||||
|
|
||||||
PyObject *rv = PyObject_CallMethod(file_obj, "close", NULL);
|
PyObject *rv = PyObject_CallMethod(file_obj, "close", NULL);
|
||||||
Py_DECREF(file_obj);
|
Py_SETREF(file_obj, NULL);
|
||||||
file_obj = NULL;
|
|
||||||
if (rv == NULL) {
|
if (rv == NULL) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1463,8 +1463,7 @@ mbstreamreader_iread(MultibyteStreamReaderObject *self,
|
||||||
goto errorexit;
|
goto errorexit;
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_DECREF(cres);
|
Py_SETREF(cres, NULL);
|
||||||
cres = NULL;
|
|
||||||
|
|
||||||
if (sizehint < 0 || buf.writer.pos != 0 || rsize == 0)
|
if (sizehint < 0 || buf.writer.pos != 0 || rsize == 0)
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -3152,8 +3152,7 @@ math_prod_impl(PyObject *module, PyObject *iterable, PyObject *start)
|
||||||
long i_result = PyLong_AsLongAndOverflow(result, &overflow);
|
long i_result = PyLong_AsLongAndOverflow(result, &overflow);
|
||||||
/* If this already overflowed, don't even enter the loop. */
|
/* If this already overflowed, don't even enter the loop. */
|
||||||
if (overflow == 0) {
|
if (overflow == 0) {
|
||||||
Py_DECREF(result);
|
Py_SETREF(result, NULL);
|
||||||
result = NULL;
|
|
||||||
}
|
}
|
||||||
/* Loop over all the items in the iterable until we finish, we overflow
|
/* Loop over all the items in the iterable until we finish, we overflow
|
||||||
* or we found a non integer element */
|
* or we found a non integer element */
|
||||||
|
@ -3200,8 +3199,7 @@ math_prod_impl(PyObject *module, PyObject *iterable, PyObject *start)
|
||||||
*/
|
*/
|
||||||
if (PyFloat_CheckExact(result)) {
|
if (PyFloat_CheckExact(result)) {
|
||||||
double f_result = PyFloat_AS_DOUBLE(result);
|
double f_result = PyFloat_AS_DOUBLE(result);
|
||||||
Py_DECREF(result);
|
Py_SETREF(result, NULL);
|
||||||
result = NULL;
|
|
||||||
while(result == NULL) {
|
while(result == NULL) {
|
||||||
item = PyIter_Next(iter);
|
item = PyIter_Next(iter);
|
||||||
if (item == NULL) {
|
if (item == NULL) {
|
||||||
|
@ -3250,8 +3248,7 @@ math_prod_impl(PyObject *module, PyObject *iterable, PyObject *start)
|
||||||
if (item == NULL) {
|
if (item == NULL) {
|
||||||
/* error, or end-of-sequence */
|
/* error, or end-of-sequence */
|
||||||
if (PyErr_Occurred()) {
|
if (PyErr_Occurred()) {
|
||||||
Py_DECREF(result);
|
Py_SETREF(result, NULL);
|
||||||
result = NULL;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -458,8 +458,7 @@ nis_maps (PyObject *module, PyObject *args, PyObject *kwdict)
|
||||||
if (!str || PyList_Append(list, str) < 0)
|
if (!str || PyList_Append(list, str) < 0)
|
||||||
{
|
{
|
||||||
Py_XDECREF(str);
|
Py_XDECREF(str);
|
||||||
Py_DECREF(list);
|
Py_SETREF(list, NULL);
|
||||||
list = NULL;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Py_DECREF(str);
|
Py_DECREF(str);
|
||||||
|
|
|
@ -4036,14 +4036,12 @@ _listdir_windows_no_opendir(path_t *path, PyObject *list)
|
||||||
Py_SETREF(v, PyUnicode_EncodeFSDefault(v));
|
Py_SETREF(v, PyUnicode_EncodeFSDefault(v));
|
||||||
}
|
}
|
||||||
if (v == NULL) {
|
if (v == NULL) {
|
||||||
Py_DECREF(list);
|
Py_SETREF(list, NULL);
|
||||||
list = NULL;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (PyList_Append(list, v) != 0) {
|
if (PyList_Append(list, v) != 0) {
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
Py_DECREF(list);
|
Py_SETREF(list, NULL);
|
||||||
list = NULL;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Py_DECREF(v);
|
Py_DECREF(v);
|
||||||
|
@ -13131,15 +13129,13 @@ os_listxattr_impl(PyObject *module, path_t *path, int follow_symlinks)
|
||||||
PyObject *attribute = PyUnicode_DecodeFSDefaultAndSize(start,
|
PyObject *attribute = PyUnicode_DecodeFSDefaultAndSize(start,
|
||||||
trace - start);
|
trace - start);
|
||||||
if (!attribute) {
|
if (!attribute) {
|
||||||
Py_DECREF(result);
|
Py_SETREF(result, NULL);
|
||||||
result = NULL;
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
error = PyList_Append(result, attribute);
|
error = PyList_Append(result, attribute);
|
||||||
Py_DECREF(attribute);
|
Py_DECREF(attribute);
|
||||||
if (error) {
|
if (error) {
|
||||||
Py_DECREF(result);
|
Py_SETREF(result, NULL);
|
||||||
result = NULL;
|
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
start = trace + 1;
|
start = trace + 1;
|
||||||
|
|
|
@ -806,8 +806,7 @@ PyObject_Format(PyObject *obj, PyObject *format_spec)
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"__format__ must return a str, not %.200s",
|
"__format__ must return a str, not %.200s",
|
||||||
Py_TYPE(result)->tp_name);
|
Py_TYPE(result)->tp_name);
|
||||||
Py_DECREF(result);
|
Py_SETREF(result, NULL);
|
||||||
result = NULL;
|
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2791,8 +2790,7 @@ PyObject_GetIter(PyObject *o)
|
||||||
"iter() returned non-iterator "
|
"iter() returned non-iterator "
|
||||||
"of type '%.100s'",
|
"of type '%.100s'",
|
||||||
Py_TYPE(res)->tp_name);
|
Py_TYPE(res)->tp_name);
|
||||||
Py_DECREF(res);
|
Py_SETREF(res, NULL);
|
||||||
res = NULL;
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -2812,8 +2810,7 @@ PyObject_GetAIter(PyObject *o) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
"aiter() returned not an async iterator of type '%.100s'",
|
"aiter() returned not an async iterator of type '%.100s'",
|
||||||
Py_TYPE(it)->tp_name);
|
Py_TYPE(it)->tp_name);
|
||||||
Py_DECREF(it);
|
Py_SETREF(it, NULL);
|
||||||
it = NULL;
|
|
||||||
}
|
}
|
||||||
return it;
|
return it;
|
||||||
}
|
}
|
||||||
|
|
|
@ -283,8 +283,7 @@ method_repr(PyMethodObject *a)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (funcname != NULL && !PyUnicode_Check(funcname)) {
|
if (funcname != NULL && !PyUnicode_Check(funcname)) {
|
||||||
Py_DECREF(funcname);
|
Py_SETREF(funcname, NULL);
|
||||||
funcname = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* XXX Shouldn't use repr()/%R here! */
|
/* XXX Shouldn't use repr()/%R here! */
|
||||||
|
@ -484,8 +483,7 @@ instancemethod_repr(PyObject *self)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (funcname != NULL && !PyUnicode_Check(funcname)) {
|
if (funcname != NULL && !PyUnicode_Check(funcname)) {
|
||||||
Py_DECREF(funcname);
|
Py_SETREF(funcname, NULL);
|
||||||
funcname = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result = PyUnicode_FromFormat("<instancemethod %V at %p>",
|
result = PyUnicode_FromFormat("<instancemethod %V at %p>",
|
||||||
|
|
|
@ -906,8 +906,7 @@ descr_new(PyTypeObject *descrtype, PyTypeObject *type, const char *name)
|
||||||
descr->d_type = (PyTypeObject*)Py_XNewRef(type);
|
descr->d_type = (PyTypeObject*)Py_XNewRef(type);
|
||||||
descr->d_name = PyUnicode_InternFromString(name);
|
descr->d_name = PyUnicode_InternFromString(name);
|
||||||
if (descr->d_name == NULL) {
|
if (descr->d_name == NULL) {
|
||||||
Py_DECREF(descr);
|
Py_SETREF(descr, NULL);
|
||||||
descr = NULL;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
descr->d_qualname = NULL;
|
descr->d_qualname = NULL;
|
||||||
|
|
|
@ -67,8 +67,7 @@ PyFile_GetLine(PyObject *f, int n)
|
||||||
}
|
}
|
||||||
if (result != NULL && !PyBytes_Check(result) &&
|
if (result != NULL && !PyBytes_Check(result) &&
|
||||||
!PyUnicode_Check(result)) {
|
!PyUnicode_Check(result)) {
|
||||||
Py_DECREF(result);
|
Py_SETREF(result, NULL);
|
||||||
result = NULL;
|
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"object.readline() returned non-string");
|
"object.readline() returned non-string");
|
||||||
}
|
}
|
||||||
|
@ -77,8 +76,7 @@ PyFile_GetLine(PyObject *f, int n)
|
||||||
const char *s = PyBytes_AS_STRING(result);
|
const char *s = PyBytes_AS_STRING(result);
|
||||||
Py_ssize_t len = PyBytes_GET_SIZE(result);
|
Py_ssize_t len = PyBytes_GET_SIZE(result);
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
Py_DECREF(result);
|
Py_SETREF(result, NULL);
|
||||||
result = NULL;
|
|
||||||
PyErr_SetString(PyExc_EOFError,
|
PyErr_SetString(PyExc_EOFError,
|
||||||
"EOF when reading a line");
|
"EOF when reading a line");
|
||||||
}
|
}
|
||||||
|
@ -95,8 +93,7 @@ PyFile_GetLine(PyObject *f, int n)
|
||||||
if (n < 0 && result != NULL && PyUnicode_Check(result)) {
|
if (n < 0 && result != NULL && PyUnicode_Check(result)) {
|
||||||
Py_ssize_t len = PyUnicode_GET_LENGTH(result);
|
Py_ssize_t len = PyUnicode_GET_LENGTH(result);
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
Py_DECREF(result);
|
Py_SETREF(result, NULL);
|
||||||
result = NULL;
|
|
||||||
PyErr_SetString(PyExc_EOFError,
|
PyErr_SetString(PyExc_EOFError,
|
||||||
"EOF when reading a line");
|
"EOF when reading a line");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1213,8 +1213,7 @@ type_repr(PyTypeObject *type)
|
||||||
if (mod == NULL)
|
if (mod == NULL)
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
else if (!PyUnicode_Check(mod)) {
|
else if (!PyUnicode_Check(mod)) {
|
||||||
Py_DECREF(mod);
|
Py_SETREF(mod, NULL);
|
||||||
mod = NULL;
|
|
||||||
}
|
}
|
||||||
name = type_qualname(type, NULL);
|
name = type_qualname(type, NULL);
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
|
@ -1288,8 +1287,7 @@ type_call(PyTypeObject *type, PyObject *args, PyObject *kwds)
|
||||||
int res = type->tp_init(obj, args, kwds);
|
int res = type->tp_init(obj, args, kwds);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
assert(_PyErr_Occurred(tstate));
|
assert(_PyErr_Occurred(tstate));
|
||||||
Py_DECREF(obj);
|
Py_SETREF(obj, NULL);
|
||||||
obj = NULL;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assert(!_PyErr_Occurred(tstate));
|
assert(!_PyErr_Occurred(tstate));
|
||||||
|
@ -5007,8 +5005,7 @@ object_repr(PyObject *self)
|
||||||
if (mod == NULL)
|
if (mod == NULL)
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
else if (!PyUnicode_Check(mod)) {
|
else if (!PyUnicode_Check(mod)) {
|
||||||
Py_DECREF(mod);
|
Py_SETREF(mod, NULL);
|
||||||
mod = NULL;
|
|
||||||
}
|
}
|
||||||
name = type_qualname(type, NULL);
|
name = type_qualname(type, NULL);
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
|
@ -8107,8 +8104,7 @@ slot_tp_hash(PyObject *self)
|
||||||
func = lookup_maybe_method(self, &_Py_ID(__hash__), &unbound);
|
func = lookup_maybe_method(self, &_Py_ID(__hash__), &unbound);
|
||||||
|
|
||||||
if (func == Py_None) {
|
if (func == Py_None) {
|
||||||
Py_DECREF(func);
|
Py_SETREF(func, NULL);
|
||||||
func = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (func == NULL) {
|
if (func == NULL) {
|
||||||
|
|
|
@ -218,8 +218,7 @@ builtin___build_class__(PyObject *self, PyObject *const *args, Py_ssize_t nargs,
|
||||||
"__class__ set to %.200R defining %.200R as %.200R";
|
"__class__ set to %.200R defining %.200R as %.200R";
|
||||||
PyErr_Format(PyExc_TypeError, msg, cell_cls, name, cls);
|
PyErr_Format(PyExc_TypeError, msg, cell_cls, name, cls);
|
||||||
}
|
}
|
||||||
Py_DECREF(cls);
|
Py_SETREF(cls, NULL);
|
||||||
cls = NULL;
|
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2483,8 +2482,7 @@ builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start)
|
||||||
long i_result = PyLong_AsLongAndOverflow(result, &overflow);
|
long i_result = PyLong_AsLongAndOverflow(result, &overflow);
|
||||||
/* If this already overflowed, don't even enter the loop. */
|
/* If this already overflowed, don't even enter the loop. */
|
||||||
if (overflow == 0) {
|
if (overflow == 0) {
|
||||||
Py_DECREF(result);
|
Py_SETREF(result, NULL);
|
||||||
result = NULL;
|
|
||||||
}
|
}
|
||||||
while(result == NULL) {
|
while(result == NULL) {
|
||||||
item = PyIter_Next(iter);
|
item = PyIter_Next(iter);
|
||||||
|
@ -2534,8 +2532,7 @@ builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start)
|
||||||
|
|
||||||
if (PyFloat_CheckExact(result)) {
|
if (PyFloat_CheckExact(result)) {
|
||||||
double f_result = PyFloat_AS_DOUBLE(result);
|
double f_result = PyFloat_AS_DOUBLE(result);
|
||||||
Py_DECREF(result);
|
Py_SETREF(result, NULL);
|
||||||
result = NULL;
|
|
||||||
while(result == NULL) {
|
while(result == NULL) {
|
||||||
item = PyIter_Next(iter);
|
item = PyIter_Next(iter);
|
||||||
if (item == NULL) {
|
if (item == NULL) {
|
||||||
|
@ -2582,8 +2579,7 @@ builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start)
|
||||||
if (item == NULL) {
|
if (item == NULL) {
|
||||||
/* error, or end-of-sequence */
|
/* error, or end-of-sequence */
|
||||||
if (PyErr_Occurred()) {
|
if (PyErr_Occurred()) {
|
||||||
Py_DECREF(result);
|
Py_SETREF(result, NULL);
|
||||||
result = NULL;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,7 @@ _PyErr_Restore(PyThreadState *tstate, PyObject *type, PyObject *value,
|
||||||
if (traceback != NULL && !PyTraceBack_Check(traceback)) {
|
if (traceback != NULL && !PyTraceBack_Check(traceback)) {
|
||||||
/* XXX Should never happen -- fatal error instead? */
|
/* XXX Should never happen -- fatal error instead? */
|
||||||
/* Well, it could be None. */
|
/* Well, it could be None. */
|
||||||
Py_DECREF(traceback);
|
Py_SETREF(traceback, NULL);
|
||||||
traceback = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save these in locals to safeguard against recursive
|
/* Save these in locals to safeguard against recursive
|
||||||
|
|
|
@ -1217,8 +1217,7 @@ r_object(RFILE *p)
|
||||||
if (!PyErr_Occurred())
|
if (!PyErr_Occurred())
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"NULL object in marshal data for tuple");
|
"NULL object in marshal data for tuple");
|
||||||
Py_DECREF(v);
|
Py_SETREF(v, NULL);
|
||||||
v = NULL;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PyTuple_SET_ITEM(v, i, v2);
|
PyTuple_SET_ITEM(v, i, v2);
|
||||||
|
@ -1244,8 +1243,7 @@ r_object(RFILE *p)
|
||||||
if (!PyErr_Occurred())
|
if (!PyErr_Occurred())
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"NULL object in marshal data for list");
|
"NULL object in marshal data for list");
|
||||||
Py_DECREF(v);
|
Py_SETREF(v, NULL);
|
||||||
v = NULL;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
PyList_SET_ITEM(v, i, v2);
|
PyList_SET_ITEM(v, i, v2);
|
||||||
|
@ -1277,8 +1275,7 @@ r_object(RFILE *p)
|
||||||
Py_DECREF(val);
|
Py_DECREF(val);
|
||||||
}
|
}
|
||||||
if (PyErr_Occurred()) {
|
if (PyErr_Occurred()) {
|
||||||
Py_DECREF(v);
|
Py_SETREF(v, NULL);
|
||||||
v = NULL;
|
|
||||||
}
|
}
|
||||||
retval = v;
|
retval = v;
|
||||||
break;
|
break;
|
||||||
|
@ -1322,8 +1319,7 @@ r_object(RFILE *p)
|
||||||
if (!PyErr_Occurred())
|
if (!PyErr_Occurred())
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
"NULL object in marshal data for set");
|
"NULL object in marshal data for set");
|
||||||
Py_DECREF(v);
|
Py_SETREF(v, NULL);
|
||||||
v = NULL;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (PySet_Add(v, v2) == -1) {
|
if (PySet_Add(v, v2) == -1) {
|
||||||
|
|
Loading…
Reference in New Issue