Message64853
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__) |
|
| Date |
User |
Action |
Args |
| 2008-04-02 13:17:18 | ncoghlan | set | spambayes_score: 0.0663347 -> 0.0663347 recipients:
+ ncoghlan, georg.brandl, terry.reedy, jkrukoff |
| 2008-04-02 13:17:18 | ncoghlan | set | spambayes_score: 0.0663347 -> 0.0663347 messageid: <1207142237.97.0.704394599034.issue643841@psf.upfronthosting.co.za> |
| 2008-04-02 13:17:17 | ncoghlan | link | issue643841 messages |
| 2008-04-02 13:17:16 | ncoghlan | create | |
|