diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_io/bytesio.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c index e4d637cc3a..8501f42ed8 100644 --- a/Modules/_io/bytesio.c +++ b/Modules/_io/bytesio.c @@ -942,8 +942,13 @@ bytesio_sizeof(bytesio *self, void *unused) Py_ssize_t res; res = _PyObject_SIZE(Py_TYPE(self)); - if (self->buf && !SHARED_BUF(self)) - res += _PySys_GetSizeOf(self->buf); + if (self->buf && !SHARED_BUF(self)) { + Py_ssize_t s = _PySys_GetSizeOf(self->buf); + if (s == -1) { + return NULL; + } + res += s; + } return PyLong_FromSsize_t(res); } |