[issue15402] Correct __sizeof__ support for struct

Serhiy Storchaka report at bugs.python.org
Thu Jul 26 22:29:22 CEST 2012


Serhiy Storchaka <storchaka at gmail.com> added the comment:

> Note that object.__sizeof__ does something slightly different, though:
> it uses basicsize (which may or may not contain the sizeof() invocation
> of the correct C structure), and it considers tp_itemsize (which may or
> may not have a correct value).

All such cases are bugs (memory manager works with tp_basicsize and 
tp_itemsize, not with __sizeof__ result) and tests do not test it. In 
paranoidal mode we should tests both __sizeof__ and object.__sizeof__. For all 
classes, even for those that do not use the extra memory. I think it is really 
tedious.

----------

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


More information about the Python-bugs-list mailing list