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.

Author ecatmur
Recipients ecatmur
Date 2013-06-17.17:34:27
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1371490468.22.0.590624884808.issue18244@psf.upfronthosting.co.za>
In-reply-to
Content
Suppose we have a class C with MRO (C, B, A, object).  C virtual-inherits an ABC V, while B virtual-inherits an unrelated ABC W:

       object
      /   |  \
      A   W  |
      | .`  /
      B`  V
      | .`
      C`

Recalling that per PEP 443 singledispatch prefers concrete bases to virtual bases, we would expect the following composed MRO:

    C, B, V, A, W, object

However what actually happens is the composed MRO depends on the order of the haystack; if W is processed first the result is correct, but if V is processed first then (because V does not subclass W) W is inserted in the MRO *before* V:

    C, B, A, object
    C, B, V, A, object
    C, B, W, V, A, object

This results in ambiguity between V and W.

Suggested fix is a slight change to the MRO composition algorithm, considering whether the items already placed in the MRO are concrete base classes.
History
Date User Action Args
2013-06-17 17:34:28ecatmursetrecipients: + ecatmur
2013-06-17 17:34:28ecatmursetmessageid: <1371490468.22.0.590624884808.issue18244@psf.upfronthosting.co.za>
2013-06-17 17:34:28ecatmurlinkissue18244 messages
2013-06-17 17:34:27ecatmurcreate