Message294415
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? |
|
Date |
User |
Action |
Args |
2017-05-25 00:13:08 | Ryan Morshead | set | recipients:
+ Ryan Morshead |
2017-05-25 00:13:08 | Ryan Morshead | set | messageid: <1495671188.71.0.216050990731.issue30469@psf.upfronthosting.co.za> |
2017-05-25 00:13:08 | Ryan Morshead | link | issue30469 messages |
2017-05-25 00:13:07 | Ryan Morshead | create | |
|