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 zzzeek
Recipients zzzeek
Date 2014-02-26.22:10:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1393452616.0.0.994094049294.issue20786@psf.upfronthosting.co.za>
In-reply-to
Content
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)
History
Date User Action Args
2014-02-26 22:10:16zzzeeksetrecipients: + zzzeek
2014-02-26 22:10:16zzzeeksetmessageid: <1393452616.0.0.994094049294.issue20786@psf.upfronthosting.co.za>
2014-02-26 22:10:15zzzeeklinkissue20786 messages
2014-02-26 22:10:15zzzeekcreate