diff options
author | Victor Stinner <vstinner@python.org> | 2022-11-14 15:21:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-14 15:21:23 (GMT) |
commit | 3e2f7135e6164860b763cf5d0d22b9dc12409767 (patch) | |
tree | d32b9ee479403299d16d9fe723618667a81591d5 /Modules/cjkcodecs | |
parent | e3d4fed07429670af631e5662086b76c1ec098c4 (diff) | |
download | cpython-3e2f7135e6164860b763cf5d0d22b9dc12409767.zip cpython-3e2f7135e6164860b763cf5d0d22b9dc12409767.tar.gz cpython-3e2f7135e6164860b763cf5d0d22b9dc12409767.tar.bz2 |
gh-99300: Use Py_NewRef() in Modules/ directory (#99469)
Replace Py_INCREF() and Py_XINCREF() with Py_NewRef() and
Py_XNewRef() in test C files of the Modules/ directory.
Diffstat (limited to 'Modules/cjkcodecs')
-rw-r--r-- | Modules/cjkcodecs/multibytecodec.c | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/Modules/cjkcodecs/multibytecodec.c b/Modules/cjkcodecs/multibytecodec.c index 4769ab2..6d67fce 100644 --- a/Modules/cjkcodecs/multibytecodec.c +++ b/Modules/cjkcodecs/multibytecodec.c @@ -141,8 +141,7 @@ codecctx_errors_get(MultibyteStatefulCodecContext *self, void *Py_UNUSED(ignored else if (self->errors == ERROR_REPLACE) errors = "replace"; else { - Py_INCREF(self->errors); - return self->errors; + return Py_NewRef(self->errors); } return PyUnicode_FromString(errors); @@ -341,8 +340,7 @@ multibytecodec_encerror(MultibyteCodec *codec, goto errorexit; } else { - Py_INCREF(tobj); - retstr = tobj; + retstr = Py_NewRef(tobj); } assert(PyBytes_Check(retstr)); @@ -786,11 +784,9 @@ encoder_encode_stateful(MultibyteStatefulEncoderContext *ctx, if (ctx->pending) { PyObject *inbuf_tmp; - Py_INCREF(ctx->pending); - origpending = ctx->pending; + origpending = Py_NewRef(ctx->pending); - Py_INCREF(ctx->pending); - inbuf_tmp = ctx->pending; + inbuf_tmp = Py_NewRef(ctx->pending); PyUnicode_Append(&inbuf_tmp, unistr); if (inbuf_tmp == NULL) goto errorexit; @@ -800,8 +796,7 @@ encoder_encode_stateful(MultibyteStatefulEncoderContext *ctx, else { origpending = NULL; - Py_INCREF(unistr); - inbuf = unistr; + inbuf = Py_NewRef(unistr); } if (PyUnicode_READY(inbuf) < 0) goto errorexit; @@ -1645,8 +1640,7 @@ mbstreamreader_new(PyTypeObject *type, PyObject *args, PyObject *kwds) } self->codec = ((MultibyteCodecObject *)codec)->codec; - self->stream = stream; - Py_INCREF(stream); + self->stream = Py_NewRef(stream); self->pendingsize = 0; self->errors = internal_error_callback(errors); if (self->errors == NULL) @@ -1869,8 +1863,7 @@ mbstreamwriter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) } self->codec = ((MultibyteCodecObject *)codec)->codec; - self->stream = stream; - Py_INCREF(stream); + self->stream = Py_NewRef(stream); self->pending = NULL; self->errors = internal_error_callback(errors); if (self->errors == NULL) |