Skip to content

Commit df5121b

Browse files
committed
gh-61481: Document that memoryview, range, and slice cannot be subclassed
Among the built-in classes that can't be subclassed, only bool documents it. memoryview, range, and slice behave the same but say nothing, so it can only be found out by trying. Add the same note to those three. The wording mirrors the existing bool entry, minus the "further" that applies only to bool (which subclasses int).
1 parent 4f3be1b commit df5121b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

Doc/library/functions.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,8 @@ are always available. They are listed here in alphabetical order.
12921292
Return a "memory view" object created from the given argument. See
12931293
:ref:`typememoryview` for more information.
12941294

1295+
This class cannot be subclassed.
1296+
12951297

12961298
.. function:: min(iterable, /, *, key=None)
12971299
min(iterable, /, *, default, key=None)
@@ -1749,6 +1751,8 @@ are always available. They are listed here in alphabetical order.
17491751
Rather than being a function, :class:`range` is actually an immutable
17501752
sequence type, as documented in :ref:`typesseq-range` and :ref:`typesseq`.
17511753

1754+
This class cannot be subclassed.
1755+
17521756

17531757
.. function:: repr(object, /)
17541758

@@ -1920,6 +1924,8 @@ are always available. They are listed here in alphabetical order.
19201924
See :func:`itertools.islice` for an alternate version that returns an
19211925
:term:`iterator`.
19221926

1927+
This class cannot be subclassed.
1928+
19231929
.. attribute:: slice.start
19241930
slice.stop
19251931
slice.step

0 commit comments

Comments
 (0)