Skip to content

Commit 4e7913f

Browse files
committed
Feedback from Alex
1 parent bf5702b commit 4e7913f

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

Doc/reference/compound_stmts.rst

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,9 +1531,10 @@ some built-in classes do not, such as :class:`bool`:
15311531
...
15321532
TypeError: type 'bool' is not an acceptable base type
15331533

1534-
To create a consistent MRO, all bases appear in the order
1535-
they were specified in the base class list and every child class must appear before its
1536-
base classes. Below is an example where this fails:
1534+
In the resolved MRO of a class, the class's bases appear in the order they were
1535+
specified in the class's bases list. Additionally, the MRO always lists a child
1536+
class before any of its bases. A class definition will fail if it is impossible to
1537+
resolve a consistent MRO that satisfies these rules from the list of bases provided:
15371538

15381539
.. doctest::
15391540

@@ -1549,9 +1550,10 @@ in the base class list, but it must also appear after ``Base`` because it is a c
15491550
``Base``. This is a contradiction, so the class cannot be defined.
15501551

15511552
If some of the bases have a custom :term:`metaclass`, the metaclass of the resulting class
1552-
is chosen among the metaclasses of the bases. It must be a metaclass that is a subclass of
1553-
all other candidate metaclasses. If no such metaclass exists, the class cannot be created,
1554-
as explained in :ref:`metaclass-determination`.
1553+
is chosen among the metaclasses of the bases and the explicitly specified metaclass of the
1554+
child class. It must be a metaclass that is a subclass of
1555+
all other candidate metaclasses. If no such metaclass exists among the candidates,
1556+
the class cannot be created, as explained in :ref:`metaclass-determination`.
15551557

15561558
Finally, the memory layouts of the bases must be compatible. This means that it must be
15571559
possible to compute a *solid base* for the class. A class is a solid base if it has a
@@ -1561,7 +1563,8 @@ depending on the Python implementation.
15611563
.. impl-detail::
15621564

15631565
In CPython, many but not all classes defined in C are solid bases, including most
1564-
builtins but excluding most concrete :class:`Exception` classes. Generally, a C class
1566+
builtins (such as :class:`int` or :class:`BaseException`)
1567+
but excluding most concrete :class:`Exception` classes. Generally, a C class
15651568
is a solid base if its underlying struct is different in size from its base class.
15661569

15671570
Every class has a solid base. :class:`object`, the base class, has itself as its solid base.
@@ -1595,7 +1598,7 @@ Example:
15951598
>>> class C3(SolidChild, Solid1): # solid base is `SolidChild`
15961599
... pass
15971600
>>>
1598-
>>> # Error: solid bases are `Solid1` and `Solid2`, but they are not subclasses of each other.
1601+
>>> # Error: solid bases are `Solid1` and `Solid2`, but neither is a subclass of the other.
15991602
>>> class C4(Solid1, Solid2): # error: no single solid base
16001603
... pass
16011604
Traceback (most recent call last):

0 commit comments

Comments
 (0)