Message241375
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 <<<<<<<<<< |
|
Date |
User |
Action |
Args |
2015-04-17 23:00:44 | belopolsky | set | recipients:
+ belopolsky, christian.heimes, ionelmc, Claudiu.Popa, ethan.furman, llllllllll |
2015-04-17 23:00:44 | belopolsky | set | messageid: <1429311644.24.0.0757297074625.issue23990@psf.upfronthosting.co.za> |
2015-04-17 23:00:44 | belopolsky | link | issue23990 messages |
2015-04-17 23:00:44 | belopolsky | create | |
|