[issue23990] Callable builtin doesn't respect descriptors

Terry J. Reedy report at bugs.python.org
Sat Apr 18 02:11:10 CEST 2015


Terry J. Reedy added the comment:

__call__ is a reserved name defined to be an instance method.  I view wrapping *any* reserved-name instance method with @property to be a bug in that it redefines the name as a data attribute implemented with a 'hidden' get method.  A function wrapped with @staticmethod or @classmethod is also not an instance method.

The doc for callable says " If this returns true, it is still possible that a call fails,"  In your example, calling a() fails with AttributeError, with or without the @property decoration.  Either way it does not contradict the doc.

The doc also says "but if it is false, calling object will never succeed."  So if you can define an object f such that callable(f) == False and print(f()) prints something, that would show a bug (and be a test case).  Failing that, this is appears to be a feature request, not a bug fix.

----------
nosy: +terry.reedy
stage:  -> test needed
type: behavior -> enhancement
versions: +Python 3.5 -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 Python-bugs-list mailing list