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 christian.heimes
Recipients Claudiu.Popa, christian.heimes, ionelmc, llllllllll
Date 2015-04-17.20:14:45
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I have closed the issue because the code behaves according to the language specs and the language design. It is not broken at all. The callable test just checks for the attribute __call__ on the *type* of an object. The check is not performed on the *object* itself.

In your example


does not do

  hasattr(a, '__call__')


  hasattr(type(a), '__call__')

which translates to

  hasattr(A, '__call__')

The behavior is very well consistent. I presume it just doesn't match your expectations. Special methods have a slightly different lookup behavior than ordinary. Due to the highly dynamic nature of Python the __call__ attribute is not validated at all.

For example this is expected behavior:

>>> class Example:
...     __call__ = None
>>> callable(Example())
>>> class Example:
...     __call__ = None
>>> example = Example()
>>> callable(example)
>>> example()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not callable
Date User Action Args
2015-04-17 20:14:45christian.heimessetrecipients: + christian.heimes, ionelmc, Claudiu.Popa, llllllllll
2015-04-17 20:14:45christian.heimessetmessageid: <>
2015-04-17 20:14:45christian.heimeslinkissue23990 messages
2015-04-17 20:14:45christian.heimescreate