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 belopolsky
Recipients Claudiu.Popa, belopolsky, christian.heimes, ethan.furman, ionelmc, llllllllll
Date 2015-04-17.23:00:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1429311644.24.0.0757297074625.issue23990@psf.upfronthosting.co.za>
In-reply-to
Content
From <https://mail.python.org/pipermail/python-ideas/2015-April/033018.html>:


>>>>>>> GvR <<<<<<<<<<
I think you've found an unintended and undocumented backdoor. I admit I don't understand how this works in CPython. Overloaded operators like __add__ or __call__ should be methods in the class, and we don't look for them in the instance. But somehow defining them with @property works (I guess because @property is in the class).

What's different for __call__ is that callable() exists. And this is probably why I exorcised it Python 3.0 -- but apparently it's back. :-(

In the end callable() doesn't always produce a correct answer; but maybe we can make it work in this case by first testing the class and then the instance? Something like (untested):

def callable(x):
    return hasattr(x.__class__, '__call__') and hasattr(x, '__call__')

>>>>>>> GvR <<<<<<<<<<
History
Date User Action Args
2015-04-17 23:00:44belopolskysetrecipients: + belopolsky, christian.heimes, ionelmc, Claudiu.Popa, ethan.furman, llllllllll
2015-04-17 23:00:44belopolskysetmessageid: <1429311644.24.0.0757297074625.issue23990@psf.upfronthosting.co.za>
2015-04-17 23:00:44belopolskylinkissue23990 messages
2015-04-17 23:00:44belopolskycreate