diff options
author | Meador Inge <meadori@gmail.com> | 2012-07-29 03:16:39 (GMT) |
---|---|---|
committer | Meador Inge <meadori@gmail.com> | 2012-07-29 03:16:39 (GMT) |
commit | 90bc2dbccef5d74f0dd6875c555ee33187cfec37 (patch) | |
tree | 1fe2b120e573bb4891ba311be0ca66e6a4f998c5 /Modules | |
parent | 4887b1c0e7a5a27a97ef2ecdae369b7d3a021f01 (diff) | |
download | cpython-90bc2dbccef5d74f0dd6875c555ee33187cfec37.zip cpython-90bc2dbccef5d74f0dd6875c555ee33187cfec37.tar.gz cpython-90bc2dbccef5d74f0dd6875c555ee33187cfec37.tar.bz2 |
Issue #15402: Simplify Struct.__sizeof__ and make tests more precise.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_struct.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/Modules/_struct.c b/Modules/_struct.c index 0a09fd8..558d24b 100644 --- a/Modules/_struct.c +++ b/Modules/_struct.c @@ -1669,15 +1669,11 @@ PyDoc_STRVAR(s_sizeof__doc__, "S.__sizeof__() -> size of S in memory, in bytes"); static PyObject * -s_sizeof(PyStructObject *self) +s_sizeof(PyStructObject *self, void *unused) { Py_ssize_t size; - formatcode *code; - size = sizeof(PyStructObject) + sizeof(formatcode); - for (code = self->s_codes; code->fmtdef != NULL; code++) { - size += sizeof(formatcode); - } + size = sizeof(PyStructObject) + sizeof(formatcode) * (self->s_len + 1); return PyLong_FromSsize_t(size); } |