You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
wow, very strange indeed ! This should definitely not happen. It is probably related to the fact that the __init__ descriptor is not called in an intuitive way by super . I'll have a look, thanks a lot for reporting !
For some reason that seems to be a python bug, super(B, self).__init__(a) is not equivalent to A.__init__(self, a) when the __init__ method is a method descriptor: InitDescriptor.__get__(obj, objtype)is called but when it is called through super, objtype is not replaced with A.
I'll have to find a workaround, that should not be too difficult. In the meantime, you can use A.__init__(self, a=self.a) as a constructor, it works.
I found a workaround but for python 3.6+ (where __setname__ callback is called when the init descriptor is attached to the class). Unfortunately for earlier versions I still have no way to determine which class owns the init method to be created. I really thought that objtype in InitDescriptor.__get__(obj, objtype) was reliable...
Activity
smarie commentedon Nov 30, 2019
wow, very strange indeed ! This should definitely not happen. It is probably related to the fact that the
__init__descriptor is not called in an intuitive way bysuper. I'll have a look, thanks a lot for reporting !smarie commentedon Nov 30, 2019
For some reason that seems to be a python bug,
super(B, self).__init__(a)is not equivalent toA.__init__(self, a)when the__init__method is a method descriptor:InitDescriptor.__get__(obj, objtype)is called but when it is called through super,objtypeis not replaced withA.I'll have to find a workaround, that should not be too difficult. In the meantime, you can use
A.__init__(self, a=self.a)as a constructor, it works.Tackled issue #53 but for python 3.7 only
smarie commentedon Nov 30, 2019
I found a workaround but for python 3.6+ (where
__setname__callback is called when the init descriptor is attached to the class). Unfortunately for earlier versions I still have no way to determine which class owns the init method to be created. I really thought thatobjtypeinInitDescriptor.__get__(obj, objtype)was reliable...devashishshankar commentedon Dec 5, 2019
Thanks, using
A.__init__(self, a=self.a)works for me.Fixed bug with `super().__init__` not behaving as expected, also with…
Merge pull request #54 from smarie/issue_53
smarie commentedon Dec 10, 2019
I finally found a "clever" way to solve this :)
It will ship in
1.0.3in a few minutes when travis has completed