https://github.com/python/cpython/commit/23b93770f6e6c6db2eef9d9b9e6ca7741489ae99
commit: 23b93770f6e6c6db2eef9d9b9e6ca7741489ae99
branch: main
author: Sergey B Kirpichev <[email protected]>
committer: hugovk <[email protected]>
date: 2026-01-11T19:17:47+02:00
summary:
gh-143420: Clarify sequence behavior for slice indexes (#143422)
files:
M Doc/library/array.rst
M Doc/library/stdtypes.rst
diff --git a/Doc/library/array.rst b/Doc/library/array.rst
index 1f04f697c7507f..5592bd7089ba49 100644
--- a/Doc/library/array.rst
+++ b/Doc/library/array.rst
@@ -9,7 +9,7 @@
--------------
This module defines an object type which can compactly represent an array of
-basic values: characters, integers, floating-point numbers. Arrays are
sequence
+basic values: characters, integers, floating-point numbers. Arrays are
mutable :term:`sequence`
types and behave very much like lists, except that the type of objects stored
in
them is constrained. The type is specified at object creation time by using a
:dfn:`type code`, which is a single character. The following type codes are
@@ -93,7 +93,7 @@ The module defines the following type:
otherwise, the initializer's iterator is passed to the :meth:`extend` method
to add initial items to the array.
- Array objects support the ordinary sequence operations of indexing, slicing,
+ Array objects support the ordinary :ref:`mutable <typesseq-mutable>`
:term:`sequence` operations of indexing, slicing,
concatenation, and multiplication. When using slice assignment, the
assigned
value must be an array object with the same type code; in all other cases,
:exc:`TypeError` is raised. Array objects also implement the buffer
interface,
diff --git a/Doc/library/stdtypes.rst b/Doc/library/stdtypes.rst
index 6118d7c556a617..d03001f1cade05 100644
--- a/Doc/library/stdtypes.rst
+++ b/Doc/library/stdtypes.rst
@@ -1093,11 +1093,14 @@ Notes:
still ``0``.
(4)
- The slice of *s* from *i* to *j* is defined as the sequence of items with
index
- *k* such that ``i <= k < j``. If *i* or *j* is greater than ``len(s)``, use
- ``len(s)``. If *i* is omitted or ``None``, use ``0``. If *j* is omitted or
- ``None``, use ``len(s)``. If *i* is greater than or equal to *j*, the
slice is
- empty.
+ The slice of *s* from *i* to *j* is defined as the sequence of items with
+ index *k* such that ``i <= k < j``.
+
+ * If *i* is omitted or ``None``, use ``0``.
+ * If *j* is omitted or ``None``, use ``len(s)``.
+ * If *i* or *j* is less than ``-len(s)``, use ``0``.
+ * If *i* or *j* is greater than ``len(s)``, use ``len(s)``.
+ * If *i* is greater than or equal to *j*, the slice is empty.
(5)
The slice of *s* from *i* to *j* with step *k* is defined as the sequence of
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]