summaryrefslogtreecommitdiff
path: root/Modules/_io/textio.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_io/textio.c')
-rw-r--r--Modules/_io/textio.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
index 8b5d00fe4a..ff903e9341 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -320,8 +320,7 @@ _PyIncrementalNewlineDecoder_decode(PyObject *myself,
out = PyUnicode_DATA(modified);
PyUnicode_WRITE(kind, out, 0, '\r');
memcpy(out + kind, PyUnicode_DATA(output), kind * output_len);
- Py_DECREF(output);
- output = modified; /* output remains ready */
+ Py_SETREF(output, modified); /* output remains ready */
self->pendingcr = 0;
output_len++;
}
@@ -336,8 +335,7 @@ _PyIncrementalNewlineDecoder_decode(PyObject *myself,
PyObject *modified = PyUnicode_Substring(output, 0, output_len -1);
if (modified == NULL)
goto error;
- Py_DECREF(output);
- output = modified;
+ Py_SETREF(output, modified);
self->pendingcr = 1;
}
}
@@ -865,8 +863,7 @@ _textiowrapper_set_decoder(textio *self, PyObject *codec_info,
self->decoder, self->readtranslate ? Py_True : Py_False, NULL);
if (incrementalDecoder == NULL)
return -1;
- Py_CLEAR(self->decoder);
- self->decoder = incrementalDecoder;
+ Py_XSETREF(self->decoder, incrementalDecoder);
}
return 0;