summaryrefslogtreecommitdiffstats
path: root/Modules/_io/bytesio.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-12-27 13:51:32 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-12-27 13:51:32 (GMT)
commit1ed017ae92b32b27186d5793f6e58c526f350a2b (patch)
tree05fec1ee9e107911f46d85f86efcabce50ff5680 /Modules/_io/bytesio.c
parent726fc139a5f40d81a0013c856be1283da08de4a0 (diff)
downloadcpython-1ed017ae92b32b27186d5793f6e58c526f350a2b.zip
cpython-1ed017ae92b32b27186d5793f6e58c526f350a2b.tar.gz
cpython-1ed017ae92b32b27186d5793f6e58c526f350a2b.tar.bz2
Issue #20440: Cleaning up the code by using Py_SETREF and Py_CLEAR.
Old code is correct, but with Py_SETREF and Py_CLEAR it can be cleaner. This patch doesn't fix bugs and hence there is no need to backport it.
Diffstat (limited to 'Modules/_io/bytesio.c')
-rw-r--r--Modules/_io/bytesio.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c
index 99e71bc..6333e46 100644
--- a/Modules/_io/bytesio.c
+++ b/Modules/_io/bytesio.c
@@ -87,7 +87,7 @@ scan_eol(bytesio *self, Py_ssize_t len)
static int
unshare_buffer(bytesio *self, size_t size)
{
- PyObject *new_buf, *old_buf;
+ PyObject *new_buf;
assert(SHARED_BUF(self));
assert(self->exports == 0);
assert(size >= (size_t)self->string_size);
@@ -96,9 +96,7 @@ unshare_buffer(bytesio *self, size_t size)
return -1;
memcpy(PyBytes_AS_STRING(new_buf), PyBytes_AS_STRING(self->buf),
self->string_size);
- old_buf = self->buf;
- self->buf = new_buf;
- Py_DECREF(old_buf);
+ Py_SETREF(self->buf, new_buf);
return 0;
}