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 ncoghlan
Recipients georg.brandl, jkrukoff, ncoghlan, terry.reedy
Date 2008-04-02.13:17:16
SpamBayes Score 0.06633475
Marked as misclassified No
Message-id <1207142237.97.0.704394599034.issue643841@psf.upfronthosting.co.za>
In-reply-to
Content
Agreed that section of the docs should be more explicit in pointing out
that __getattr__ and __getattribute__ won't work for proxying special
methods for new-style classes.

It's also true that there are quite a few special methods where nothing
special is needed to correctly proxy the methods. That said, defining
all of the methods blindly is also bad (as a lot of informal type
testing is done by checking for certain special methods as attributes).

Perhaps it would be useful to have a method on type instances that could
be explicitly invoked to tell the type to run through all the tp_* slots
and populate them based on doing getattr(self, "__slotname__").

(Note that it's only those methods with dedicated slots in the C type
structure that are a problem here - those which are implemented solely
as normal Python methods like __enter__, __exit__ or the pickle module's
special methods can typically be overridden as expected through the use
of __getattr__ and __getattribute__)
History
Date User Action Args
2008-04-02 13:17:18ncoghlansetspambayes_score: 0.0663347 -> 0.06633475
recipients: + ncoghlan, georg.brandl, terry.reedy, jkrukoff
2008-04-02 13:17:18ncoghlansetspambayes_score: 0.0663347 -> 0.0663347
messageid: <1207142237.97.0.704394599034.issue643841@psf.upfronthosting.co.za>
2008-04-02 13:17:17ncoghlanlinkissue643841 messages
2008-04-02 13:17:16ncoghlancreate