This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2001年11月15日 06:29 by tim.peters, last changed 2022年04月10日 16:04 by admin. This issue is now closed.
| Messages (2) | |||
|---|---|---|---|
| msg7564 - (view) | Author: Tim Peters (tim.peters) * (Python committer) | Date: 2001年11月15日 06:29 | |
Dubious MRO from mixing classic and new-style classes in multiple inheritance: > def mrolist(k): > return ' '.join([c.__name__ for c in k.__mro__]) > > def f(): > # No question here. > class C: pass > class M1(C, object): pass > print mrolist(M1) # "M1 C object" > > # And no question here. > class D(C): pass > class M2(object, D): pass > print mrolist(M2) # "M2 object D C" > > # Here I expected > # "M3 M1 M2 object D C" > # but got > # "M3 M1 M2 D C object" > class M3(M1, M2): pass > print mrolist(M3) > > f() """ If I add class M4(M2, M1): pass print mrolist(M4) this prints what you may have expected: M4 M2 M1 object D C My conclusion is that it's an artefact of how conservative_merge() resolves the conflict between M1 and M2: in M1, C preceeds object, while in M2, object preceeds C. This order conflict is supposed to be outlawed, but I didn't feel like testing for it -- the function serious_order_disagreements() always returns false. In the light of conflicts, the algorithm in conservative() apparently favors the order of the first base class encountered. """ |
|||
| msg7565 - (view) | Author: Guido van Rossum (gvanrossum) * (Python committer) | Date: 2002年03月23日 03:48 | |
Logged In: YES user_id=6380 Closing as Won't Fix. In the light of conflicts, the MRO algorithm can yield surprises, yes. Then don't do that. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月10日 16:04:38 | admin | set | github: 35530 |
| 2001年11月15日 06:29:37 | tim.peters | create | |