Alexander Belopolsky added the comment:
>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 <<<<<<<<<<
----------
nosy: +belopolsky
resolution: not a bug ->
stage: resolved ->
status: closed -> open
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue23990>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com