We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bdbad71 commit 36dcaabCopy full SHA for 36dcaab
Modules/_io/bytesio.c
@@ -943,8 +943,13 @@ bytesio_sizeof(bytesio *self, void *unused)
943
Py_ssize_t res;
944
945
res = _PyObject_SIZE(Py_TYPE(self));
946
- if (self->buf && !SHARED_BUF(self))
947
- res += _PySys_GetSizeOf(self->buf);
+ if (self->buf && !SHARED_BUF(self)) {
+ Py_ssize_t s = _PySys_GetSizeOf(self->buf);
948
+ if (s == -1) {
949
+ return NULL;
950
+ }
951
+ res += s;
952
953
return PyLong_FromSsize_t(res);
954
}
955
0 commit comments