gh-99537: Use Py_CLEAR() function in C code (#99686)

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.
This commit is contained in:
Victor Stinner 2022-11-22 15:22:55 +01:00 committed by GitHub
parent 7e3f09cad9
commit 9a91182d4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 12 deletions

View file

@ -2383,8 +2383,7 @@ channel_list_interpreters(PyObject *self, PyObject *args, PyObject *kwds)
goto finally;
except:
Py_XDECREF(ids);
ids = NULL;
Py_CLEAR(ids);
finally:
return ids;