From 8211cf5d287acfd815b6a7f6471cdf83dcd2bb9b Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 16 Nov 2022 18:34:24 +0100 Subject: gh-99300: Replace Py_INCREF() with Py_NewRef() (#99530) Replace Py_INCREF() and Py_XINCREF() using a cast with Py_NewRef() and Py_XNewRef(). --- Python/codecs.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'Python/codecs.c') diff --git a/Python/codecs.c b/Python/codecs.c index 64addf00d5..b2087b499d 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; } -- cgit v1.2.1