diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-19 18:07:11 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-12-19 18:07:11 (GMT) |
commit | a9406e77fa7bd3618c16edd248c24010af7035c1 (patch) | |
tree | 885dac8e53616cebafbb37bc5613040513bd9581 /Modules/_io | |
parent | a254921cd4c1ca22d725872601292c48b7caa20a (diff) | |
parent | 5c4064e8bd199d70eefd7ec24766957c22f1b8e8 (diff) | |
download | cpython-a9406e77fa7bd3618c16edd248c24010af7035c1.zip cpython-a9406e77fa7bd3618c16edd248c24010af7035c1.tar.gz cpython-a9406e77fa7bd3618c16edd248c24010af7035c1.tar.bz2 |
Issue #25421: __sizeof__ methods of builtin types now use dynamic basic size.
This allows sys.getsize() to work correctly with their subclasses with
__slots__ defined.
Diffstat (limited to 'Modules/_io')
-rw-r--r-- | Modules/_io/bufferedio.c | 2 | ||||
-rw-r--r-- | Modules/_io/bytesio.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index 29e000b..6bb2200 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -423,7 +423,7 @@ buffered_sizeof(buffered *self, void *unused) { Py_ssize_t res; - res = sizeof(buffered); + res = _PyObject_SIZE(Py_TYPE(self)); if (self->buffer) res += self->buffer_size; return PyLong_FromSsize_t(res); diff --git a/Modules/_io/bytesio.c b/Modules/_io/bytesio.c index 31cc1f7..eef3b3d 100644 --- a/Modules/_io/bytesio.c +++ b/Modules/_io/bytesio.c @@ -991,7 +991,7 @@ bytesio_sizeof(bytesio *self, void *unused) { Py_ssize_t res; - res = sizeof(bytesio); + res = _PyObject_SIZE(Py_TYPE(self)); if (self->buf && !SHARED_BUF(self)) res += _PySys_GetSizeOf(self->buf); return PyLong_FromSsize_t(res); |