This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author benjamin.peterson
Recipients Arfrever, Trundle, barry, benjamin.peterson, eric.araujo, jcea, michael.foord, ncoghlan, r.david.murray, rhettinger, soren
Date 2011-06-04.18:53:52
SpamBayes Score 1.3750024e-07
Marked as misclassified No
Message-id <BANLkTinruXPqSG-K7dCggZ6o2Wv_XEV=Dg@mail.gmail.com>
In-reply-to <1307212964.67.0.685232672857.issue12248@psf.upfronthosting.co.za>
Content
2011/6/4 Soren Hansen <report@bugs.python.org>:
>
> Soren Hansen <soren@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__()?

Yes, this is a limitation of magic methods on old style classes. The
usual method is something like this:

    def __getattr__(self, name):
        if name == "__dir__":
            return self.__dir__
        # Other stuff

Of course, the best fix is to use new-style classes. :)
History
Date User Action Args
2011-06-04 18:53:53benjamin.petersonsetrecipients: + benjamin.peterson, barry, rhettinger, jcea, ncoghlan, eric.araujo, Arfrever, r.david.murray, michael.foord, Trundle, soren
2011-06-04 18:53:52benjamin.petersonlinkissue12248 messages
2011-06-04 18:53:52benjamin.petersoncreate