mirror of
https://github.com/python/cpython.git
synced 2025-09-24 17:33:29 +00:00
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
22 changed files with 44 additions and 87 deletions
|
@ -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));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue