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 Ryan Morshead
Recipients Ryan Morshead
Date 2017-05-25.00:13:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1495671188.71.0.216050990731.issue30469@psf.upfronthosting.co.za>
In-reply-to
Content
When the `__get__`, `__set__`, or `__delete__` attribute of a descriptor is not a method, and is instead a generic callable, the first argument of that callable is inconsistent:


    class Callable(object):

        def __call__(self, first, *args, **kwargs):
            print(first)


    class Descriptor(object):

        __set__ = Callable()
        __delete__ = Callable()
        __get__ = Callable()


    class MyClass(object):

        d = Descriptor()


    mc = MyClass()
    mc.d = 1
    del mc.d
    mc.d


Prints:


    <__main__.MyClass object at 0x10854cda0>
    <__main__.MyClass object at 0x10854cda0>
    <__main__.Descriptor object at 0x10855f240>


As it turns out, this occurs because `slot_tp_descr_set` (shared by `__set__` and `__delete__`) and `slot_tp_descr_get` just aren't consistent in their implementation.

See: https://stackoverflow.com/questions/44169370/strange-descriptor-behavior/44169805#44169805

Is this behavior intentional? If not, how ought this case be handled?
History
Date User Action Args
2017-05-25 00:13:08Ryan Morsheadsetrecipients: + Ryan Morshead
2017-05-25 00:13:08Ryan Morsheadsetmessageid: <1495671188.71.0.216050990731.issue30469@psf.upfronthosting.co.za>
2017-05-25 00:13:08Ryan Morsheadlinkissue30469 messages
2017-05-25 00:13:07Ryan Morsheadcreate