[issue12248] __dir__ semantics changed in Python 2.7.2

Soren Hansen report at bugs.python.org
Sat Jun 4 20:42:44 CEST 2011


Soren Hansen <soren at linux2go.dk> added the comment:

When I first investigated this problem (I reported the original bug on Launchpad), my first attempt to address this issue in pymox had me quite stumped. The class in question has a __getattr__ method. Up until now, this hasn't affected the use of dir(), but it does now. I really just wanted it return whatever it used to return (since that has worked so far), but realising that this was an old-style class, I couldn't just call super(TheClass, self).__dir__().

So my question is: If this change stays (which seems clear given that the only changes proposed here are ways of relaxing the type requirement of the __dir__ method's return value, not reverting the change altogether), and I have an old-style class with a __getattr__ defined, how do I make that class return whatever it would have usually returned for __dir__()?

----------
nosy: +soren

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


More information about the Python-bugs-list mailing list