<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Sat, Nov 18, 2017 at 9:29 PM Nick Coghlan <<a href="mailto:ncoghlan@gmail.com">ncoghlan@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 19 November 2017 at 06:56, Neil Girdhar <<a href="mailto:mistersheik@gmail.com" target="_blank">mistersheik@gmail.com</a>> wrote:<br>
> Would you mind explaining why it's necessary for C3 to complain?<br>
><br>
> In:<br>
><br>
> S < C<br>
> B < S, E<br>
> R < E, C<br>
> Z < B, R<br>
><br>
> If Z is told to have MRO:<br>
><br>
> (Z, B, S, R, E, C)<br>
><br>
> then there are no conflicts with any base classes.<br>
<br>
I don't actually know what C3 allows in principle, I only know that<br>
CPython's resolver still complains in practice:<br>
<br>
    >>> class C: pass<br>
    ...<br>
    >>> class S(C): pass<br>
    ...<br>
    >>> class E: pass<br>
    ...<br>
    >>> class B(S, E): pass<br>
    ...<br>
    >>> class R(E, C): pass<br>
    ...<br>
    >>> class Z(B, S, R, E, C): pass<br>
    ...<br>
    Traceback (most recent call last):<br>
     File "<stdin>", line 1, in <module><br>
    TypeError: Cannot create a consistent method resolution order<br>
(MRO) for bases C, E<br>
<br>
I think the problem is that the resolver isn't looking at the declared<br>
bases of "B", and "R", it's looking at their full MRO:<br>
<br>
    >>> B.__mro__<br>
    (<class '__main__.B'>, <class '__main__.S'>, <class '__main__.C'>,<br>
<class '__main__.E'>, <class 'object'>)<br>
    >>> R.__mro__<br>
    (<class '__main__.R'>, <class '__main__.E'>, <class '__main__.C'>,<br>
<class 'object'>)<br>
<br>
Changing the heuristics used to generate B's MRO such that "C" and "E"<br>
appeared in the opposite order wouldn't really help, since that would<br>
just flip the problematic case to be the "R(C, E)" declaration.<br></blockquote><div><br></div><div>Sorry, I wrote back too quickly.  I meant also to change B's requested MRO to be:</div><div><br></div><div>(B, S, E, C)</div><div><br></div><div>It works with that change.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Cheers,<br>
Nick.<br>
<br>
--<br>
Nick Coghlan   |   <a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>   |   Brisbane, Australia<br>
</blockquote></div></div>