Message241352
| Author |
ionelmc |
| Recipients |
ionelmc |
| Date |
2015年04月17日.18:52:48 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1429296768.81.0.194105997153.issue23990@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
It appears that callable doesn't really care for the descriptor protocol, so it return True even if __call__ is actually an descriptor that raise AttributeError (clearly not callable at all).
Eg:
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> callable
<built-in function callable>
>>> class A:
... @property
... def __call__(self):
... raise AttributeError('go away')
...
>>> a = A()
>>> a
<__main__.A object at 0x000000000365B5C0>
>>> a.__call__
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<stdin>", line 4, in __call__
AttributeError: go away
>>> callable(a)
True
>>> # it should be False :( |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2015年04月17日 18:52:48 | ionelmc | set | recipients:
+ ionelmc |
| 2015年04月17日 18:52:48 | ionelmc | set | messageid: <1429296768.81.0.194105997153.issue23990@psf.upfronthosting.co.za> |
| 2015年04月17日 18:52:48 | ionelmc | link | issue23990 messages |
| 2015年04月17日 18:52:48 | ionelmc | create |
|