diff options
author | Victor Stinner <vstinner@python.org> | 2022-11-16 17:34:24 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-16 17:34:24 (GMT) |
commit | 8211cf5d287acfd815b6a7f6471cdf83dcd2bb9b (patch) | |
tree | 510409237622aa30dfc6833602bdde97c578f2bb /Python/codecs.c | |
parent | 19c1462e8dca3319c8290e2edcce482bd18cb018 (diff) | |
download | cpython-8211cf5d287acfd815b6a7f6471cdf83dcd2bb9b.zip cpython-8211cf5d287acfd815b6a7f6471cdf83dcd2bb9b.tar.gz cpython-8211cf5d287acfd815b6a7f6471cdf83dcd2bb9b.tar.bz2 |
gh-99300: Replace Py_INCREF() with Py_NewRef() (#99530)
Replace Py_INCREF() and Py_XINCREF() using a cast with Py_NewRef()
and Py_XNewRef().
Diffstat (limited to 'Python/codecs.c')
-rw-r--r-- | Python/codecs.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/Python/codecs.c b/Python/codecs.c index 64addf0..b2087b4 100644 --- a/Python/codecs.c +++ b/Python/codecs.c @@ -428,8 +428,7 @@ _PyCodec_EncodeInternal(PyObject *object, "encoder must return a tuple (object, integer)"); goto onError; } - v = PyTuple_GET_ITEM(result,0); - Py_INCREF(v); + v = Py_NewRef(PyTuple_GET_ITEM(result,0)); /* We don't check or use the second (integer) entry. */ Py_DECREF(args); @@ -473,8 +472,7 @@ _PyCodec_DecodeInternal(PyObject *object, "decoder must return a tuple (object,integer)"); goto onError; } - v = PyTuple_GET_ITEM(result,0); - Py_INCREF(v); + v = Py_NewRef(PyTuple_GET_ITEM(result,0)); /* We don't check or use the second (integer) entry. */ Py_DECREF(args); @@ -569,8 +567,7 @@ PyObject *codec_getitem_checked(const char *encoding, if (codec == NULL) return NULL; - v = PyTuple_GET_ITEM(codec, index); - Py_INCREF(v); + v = Py_NewRef(PyTuple_GET_ITEM(codec, index)); Py_DECREF(codec); return v; } |