New submission from mike bayer: The Python builtin property() historically does not allow inspect.getargspec to be called on any of __get__(), __set__(), or __delete__(). As of 3.4, it seems that this call now succeeds. However the answer it gives for __delete__() seems to be incorrect. Below illustrates that property.__delete__() accepts two arguments "self" and "instance" but inspect is giving a misleading answer:
import inspect # userland descriptor class Descriptor(object): def __get__(self, instance, owner): if instance is None: return self def __set__(self, instance, value): pass def __delete__(self, instance): pass # class with property + userland descriptor class X(object): @property def foo(self): pass @foo.deleter def foo(self): pass bar = Descriptor() # property.__delete__ and Descriptor.__delete__ both accept two arguments: property.__delete__(X.foo, X()) Descriptor.__delete__(X.bar, X()) # on all versions, userland __delete__ produces 'self', 'instance' for args assert inspect.getargspec(Descriptor.__delete__) == (['self', 'instance'], None, None, None) try: # but on python 3.4, it returns ['instance'] insp = inspect.getargspec(property.__delete__) assert insp == (['self', 'instance'], None, None, None), insp except TypeError as e: # on all other python versions, raises # <slot wrapper '__delete__' of 'property' objects> is not a Python function print("Exception: %s" % e) ---------- messages: 212313 nosy: zzzeek priority: normal severity: normal status: open title: inspect.getargspec() returns wrong answer with property.__delete__() versions: Python 3.4 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20786> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com