mirror of
https://github.com/python/cpython.git
synced 2025-12-31 04:23:37 +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
|
|
@ -806,8 +806,7 @@ PyObject_Format(PyObject *obj, PyObject *format_spec)
|
|||
PyErr_Format(PyExc_TypeError,
|
||||
"__format__ must return a str, not %.200s",
|
||||
Py_TYPE(result)->tp_name);
|
||||
Py_DECREF(result);
|
||||
result = NULL;
|
||||
Py_SETREF(result, NULL);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
@ -2791,8 +2790,7 @@ PyObject_GetIter(PyObject *o)
|
|||
"iter() returned non-iterator "
|
||||
"of type '%.100s'",
|
||||
Py_TYPE(res)->tp_name);
|
||||
Py_DECREF(res);
|
||||
res = NULL;
|
||||
Py_SETREF(res, NULL);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
|
@ -2812,8 +2810,7 @@ PyObject_GetAIter(PyObject *o) {
|
|||
PyErr_Format(PyExc_TypeError,
|
||||
"aiter() returned not an async iterator of type '%.100s'",
|
||||
Py_TYPE(it)->tp_name);
|
||||
Py_DECREF(it);
|
||||
it = NULL;
|
||||
Py_SETREF(it, NULL);
|
||||
}
|
||||
return it;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue