diff options
| author | Victor Stinner <vstinner@python.org> | 2022-11-23 14:57:50 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-11-23 14:57:50 +0100 |
| commit | 81f7359f67a7166d57a10a3d5366406d9c85f1de (patch) | |
| tree | f72a35747fa77ab9c63ba70ef9e1620daddf0cc3 /Modules/mathmodule.c | |
| parent | 5d9183c7ad68eb9ddb53d54a3f9a27e29dbabf31 (diff) | |
| download | cpython-git-81f7359f67a7166d57a10a3d5366406d9c85f1de.tar.gz | |
gh-99537: Use Py_SETREF(var, NULL) in C code (#99687)
Replace "Py_DECREF(var); var = NULL;" with "Py_SETREF(var, NULL);".
Diffstat (limited to 'Modules/mathmodule.c')
| -rw-r--r-- | Modules/mathmodule.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/Modules/mathmodule.c b/Modules/mathmodule.c index 83eb338be9..49c0293d4f 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; } |
