diff options
author | Victor Stinner <vstinner@python.org> | 2022-11-10 22:22:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-10 22:22:02 +0100 |
commit | 584e55bd34a38a0bd4b6ed3534fdbf7dc35c64b0 (patch) | |
tree | 3eb2005170635a27dc24516ace42a4cca741be38 /Objects/iterobject.c | |
parent | 2f4af2d99cffed6ba81e4b8fd886de6ae8625a3f (diff) | |
download | cpython-git-584e55bd34a38a0bd4b6ed3534fdbf7dc35c64b0.tar.gz |
gh-99300: Use Py_NewRef() in Objects/ directory (#99335)
Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and
Py_XNewRef() in C files of the Objects/ directory.
Diffstat (limited to 'Objects/iterobject.c')
-rw-r--r-- | Objects/iterobject.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/Objects/iterobject.c b/Objects/iterobject.c index 62c36146d6..cfd6d0a7c9 100644 --- a/Objects/iterobject.c +++ b/Objects/iterobject.c @@ -23,8 +23,7 @@ PySeqIter_New(PyObject *seq) if (it == NULL) return NULL; it->it_index = 0; - Py_INCREF(seq); - it->it_seq = seq; + it->it_seq = Py_NewRef(seq); _PyObject_GC_TRACK(it); return (PyObject *)it; } @@ -183,10 +182,8 @@ PyCallIter_New(PyObject *callable, PyObject *sentinel) it = PyObject_GC_New(calliterobject, &PyCallIter_Type); if (it == NULL) return NULL; - Py_INCREF(callable); - it->it_callable = callable; - Py_INCREF(sentinel); - it->it_sentinel = sentinel; + it->it_callable = Py_NewRef(callable); + it->it_sentinel = Py_NewRef(sentinel); _PyObject_GC_TRACK(it); return (PyObject *)it; } @@ -496,10 +493,8 @@ PyAnextAwaitable_New(PyObject *awaitable, PyObject *default_value) if (anext == NULL) { return NULL; } - Py_INCREF(awaitable); - anext->wrapped = awaitable; - Py_INCREF(default_value); - anext->default_value = default_value; + anext->wrapped = Py_NewRef(awaitable); + anext->default_value = Py_NewRef(default_value); _PyObject_GC_TRACK(anext); return (PyObject *)anext; } |