[issue15402] Correct __sizeof__ support for struct

Meador Inge report at bugs.python.org
Sat Jul 28 18:35:19 CEST 2012


Meador Inge added the comment:

On Sat, Jul 28, 2012 at 3:27 AM, Serhiy Storchaka
<report at bugs.python.org> wrote:

> Serhiy Storchaka <storchaka at gmail.com> added the comment:
>
>> issue15456
>> efficiently demonstrates that the current style can detect bugs
>> which testing with object.__sizeof__ can't.
>
> Hmm, I see this as a counterexample. The bug *was not detected* with the
> current style of testing.

I disagree.  It wasn't *directly* detected -- the test broke because of the new
structure field that was added and not because of the new dynamic memory
allocation that was added.  Even so, the fact that the test broke *at all*
should have thrown a warning flag up in the developer's mind to reevaluate
how the size is calculated.  If the test were written using your
object.__sizeof__
method, then the test would not have broken *at all* and therefore it might not
have even crossed the developers mind to verify whether the sizeof calculation
is correct.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15402>
_______________________________________


More information about the Python-bugs-list mailing list