summaryrefslogtreecommitdiffstats
path: root/Modules/cjkcodecs
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/cjkcodecs')
-rw-r--r--Modules/cjkcodecs/multibytecodec.c21
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)