[New-bugs-announce] [issue23990] Callable builtin doesn't respect descriptors
Maries Ionel Cristian
report at bugs.python.org
Fri Apr 17 20:52:48 CEST 2015
New submission from Maries Ionel Cristian:
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 :(
----------
components: Interpreter Core
messages: 241352
nosy: ionel.mc
priority: normal
severity: normal
status: open
title: Callable builtin doesn't respect descriptors
type: behavior
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23990>
_______________________________________
More information about the New-bugs-announce
mailing list