File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
python/ql/lib/semmle/python/dataflow/new/internal Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -679,6 +679,7 @@ Class getADirectSubclass(Class cls) { cls = getADirectSuperclass(result) }
679679 * For more info on the C3 MRO used in Python see:
680680 * - https://docs.python.org/3/glossary.html#term-method-resolution-order
681681 * - https://www.python.org/download/releases/2.3/mro/
682+ * - https://opendylan.org/_static/c3-linearization.pdf
682683 */
683684private Class getNextClassInMro ( Class cls ) {
684685 // class A(B, ...):
@@ -693,13 +694,21 @@ private Class getNextClassInMro(Class cls) {
693694 sub .getBase ( i + 1 ) = classTracker ( result ) .asExpr ( ) and
694695 not result = cls
695696 )
696- // There are two important properties for MRO computed with C3 in Python:
697+ // There are three important properties for MRO computed with C3 in Python:
697698 //
698699 // 1) monotonicity: if C1 precedes C2 in the MRO of C, then C1 precedes C2 in the MRO
699700 // of any subclass of C.
700701 // 2) local precedence ordering: if C1 precedes C2 in the list of superclasses for C,
701702 // they will keep the same order in the MRO for C (and due to monotonicity, any
702703 // subclass).
704+ // 3) consistency with the extended precedence graph: if A and B (that are part of the
705+ // class hierarchy of C) do not have a subclass/superclass relationship on their
706+ // own, the ordering of A and B in the MRO of C will be determined by the local
707+ // precedence ordering in the classes that use both A and B, either directly or
708+ // through a subclass. (see paper for more details)
709+ //
710+ // Note that not all class hierarchies are allowed with C3, see the Python 2.3 article
711+ // for examples.
703712}
704713
705714/**
You can’t perform that action at this time.
0 commit comments