← index #525Issue #624
Related · high · value 0.307
QUERY · ISSUE

Method Resolution Order (MRO) is not compliant

openby pfalconopened 2014-04-28updated 2024-08-28
py-core

uPy currently implements depth-first MRO, which is equivalent to one used pre-Python2.2.
References:

  • http://python-history.blogspot.com/2010/06/method-resolution-order.html
  • https://www.python.org/download/releases/2.3/mro/
CANDIDATE · ISSUE

To support multiple inheritance, should filter out "object" from base class spec and handle it as implicit fallback

closedby pfalconopened 2014-05-22updated 2022-06-23
bug

We're not going to get proper Python MRO any time soon (#525), but to at least not break multiple inheritance (MI) in obvious way, we should at least do following:

  1. Filter out "object" from any explicit base class specification. (turn class Foo(object) into class Foo).
  2. Look up attributes in "object" as a fallback.

This will emulate the fact that in Python3, "object" is always the last type in MRO.

Failing to do the above may mean, that with our naive depth-first MRO, "object" ultimate base of first superclass in MI case may seize method call destined to another superclass, if "object" has such method. With #520 & #606, object now implements __new__ and __init__, so any other multi-superclass will be denied construction and initialization.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied