[issue3122] sys.getsizeof() gives an AttributeError for _sre objects.

Robert Schuppenies report at bugs.python.org
Thu Jul 3 15:31:49 CEST 2008


Robert Schuppenies <okkotonushi at googlemail.com> added the comment:

Amaury,
I was testing your patch and it turns out, that it will ignore
any __sizeof__ attribute which may be available through getattr. I
adapted it a bit, so now getsizeof will try to call the method on the
passed object first, and if it fails or the object is a type, the code
proposed by you will be executed. This also deals with old-style class
instances. The match_sizeof function in the patch is just to showcase
the example. What do you think?

Added file: http://bugs.python.org/file10802/sizeof2.patch

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


More information about the Python-bugs-list mailing list