[issue38171] super() is passing wrong parameters while handling diamond inheritance

Patrick Monnerat report at bugs.python.org
Sat Sep 14 09:35:27 EDT 2019


New submission from Patrick Monnerat <patrick at monnerat.net>:

Running the attached program outputs:
--------
top.__init__(<__main__.top object at 0x7fc1dea24048>,) called
i1.__init__(<__main__.top object at 0x7fc1dea24048>, 'arg from top') called
i2.__init__(<__main__.top object at 0x7fc1dea24048>, 'arg from i1') called
base.__init__(<__main__.top object at 0x7fc1dea24048>, 'arg from i2') called
base.__init__ returns None
i2.__init__ returns None
i1.__init__ returns None
top.__init__ returns None
--------

i2.__init__() argument is wrong: since it is is not a parent class of i1, it should be "arg from top".

I can understand i2.__init__() is called after i1.__init__() and before base.__init__() but arguments given to super(i1, self).__init__() should not be substituted for calling i2.__init__().

----------
files: super.py
messages: 352429
nosy: monnerat
priority: normal
severity: normal
status: open
title: super() is passing wrong parameters while handling diamond inheritance
type: behavior
Added file: https://bugs.python.org/file48608/super.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38171>
_______________________________________


More information about the Python-bugs-list mailing list