New submission from Arno-Can Uestuensoez <acue.opensou...@gmail.com>:

The attached examples evaluate inheritance by mixins with different
arameters and in different orders.

The 'super()' call propagates the call resolution by definition
to the next level, and cares about multiple inheritance as well
as mixins. Where mixins are the superior case as they represent multiple 
inheritance in any case due to the common top class 'object'.
So far perfect.

The oddity I came around is the simple case of mixins with different
parameters, where both are derived from 'object'. It is obvious, that such a 
class has to comply to the parents call interface - here object - when to be 
used standalone. BUT when I ignore this and set intentionally a parameter - for 
test-purposes of mixins only - the resolution algorithm seems to normalize both 
for the final call without parameters -  as soon as one of the mixins is a 
non-parameter call. This is independent from the inheritance order for the 
derived class.

I expect for the rightmost of the inherited classes to pass the parameters 
literally.

When both classes have parameters, the parameter is passed to 'object' and 
correctly raises an exception.

#----------------------------------------------------------

[acue@lap001 mixin-order-with-different-params]$ ./call.sh 

************************

different parameters for mixin classes at diffeent positions

  0: super() method signature has no param
  1: super() method signature has param

final top-class is 'object()' which does not know the 
parameter - here 'propagate'

************************

#---------------
#
# CALL: mixin_C_is_A1B0.py
#
B:C
A:C
C:C

#---------------
#
# CALL: mixin_C_is_A1B1.py
#
Traceback (most recent call last):
  File "mixin_C_is_A1B1.py", line 24, in <module>
    c=C(True)        
  File "mixin_C_is_A1B1.py", line 20, in __init__
    super(C, self).__init__(propagate)
  File "mixin_C_is_A1B1.py", line 4, in __init__
    super(A, self).__init__(propagate)
  File "mixin_C_is_A1B1.py", line 12, in __init__
    super(B, self).__init__(propagate)
TypeError: object.__init__() takes no parameters

#---------------
#
# CALL: mixin_C_is_B0A1.py
#
A:C
B:C
C:C

#---------------
#
# CALL: mixin_C_is_B1A1.py
#
Traceback (most recent call last):
  File "mixin_C_is_B1A1.py", line 25, in <module>
    c=C(True)        
  File "mixin_C_is_B1A1.py", line 20, in __init__
    super(C, self).__init__(propagate)
  File "mixin_C_is_B1A1.py", line 12, in __init__
    super(B, self).__init__(propagate)
  File "mixin_C_is_B1A1.py", line 4, in __init__
    super(A, self).__init__(propagate)
TypeError: object.__init__() takes no parameters

[acue@lap001 mixin-order-with-different-params]$ 


#----------------------------------------------


Is this intentional?

If so, what is the explanation? - Because it potentially hides bugs for later 
debugging...

----------
files: tests.tar.gz
messages: 353062
nosy: acue
priority: normal
severity: normal
status: open
title: Mixins - super calls in bases of multiple-inheritance with different 
parameters
type: compile error
versions: Python 2.7, Python 3.6
Added file: https://bugs.python.org/file48621/tests.tar.gz

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue38262>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to