summaryrefslogtreecommitdiffstats
path: root/Modules/_io/bufferedio.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-11-30 16:22:52 (GMT)
committerGitHub <noreply@github.com>2022-11-30 16:22:52 (GMT)
commit85dd6cb6df996b1197266d1a50ecc9187a91e481 (patch)
tree774e93130f5e1b81dcd7a94982c189c718e84b91 /Modules/_io/bufferedio.c
parent18a6967544795cdcce45b45700b7a9ed3994b8fb (diff)
downloadcpython-85dd6cb6df996b1197266d1a50ecc9187a91e481.zip
cpython-85dd6cb6df996b1197266d1a50ecc9187a91e481.tar.gz
cpython-85dd6cb6df996b1197266d1a50ecc9187a91e481.tar.bz2
gh-99845: Use size_t type in __sizeof__() methods (#99846)
The implementation of __sizeof__() methods using _PyObject_SIZE() now use an unsigned type (size_t) to compute the size, rather than a signed type (Py_ssize_t). Cast explicitly signed (Py_ssize_t) values to unsigned type (Py_ssize_t).
Diffstat (limited to 'Modules/_io/bufferedio.c')
-rw-r--r--Modules/_io/bufferedio.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index e261093..6df55b5 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -389,12 +389,11 @@ buffered_dealloc(buffered *self)
static PyObject *
buffered_sizeof(buffered *self, PyObject *Py_UNUSED(ignored))
{
- Py_ssize_t res;
-
- res = _PyObject_SIZE(Py_TYPE(self));
- if (self->buffer)
- res += self->buffer_size;
- return PyLong_FromSsize_t(res);
+ size_t res = _PyObject_SIZE(Py_TYPE(self));
+ if (self->buffer) {
+ res += (size_t)self->buffer_size;
+ }
+ return PyLong_FromSize_t(res);
}
static int