[3.14] gh-118803: Improve documentation around ByteString deprecation (GH-139115) (#139136)

gh-118803: Improve documentation around `ByteString` deprecation (GH-139115)
(cherry picked from commit 4305cc3ef3)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-09-18 19:54:43 +02:00 committed by GitHub
parent e560865120
commit 665a3495bf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 94 additions and 20 deletions

View file

@ -1082,9 +1082,13 @@ def __instancecheck__(cls, instance):
return super().__instancecheck__(instance)
class ByteString(Sequence, metaclass=_DeprecateByteStringMeta):
"""This unifies bytes and bytearray.
"""Deprecated ABC serving as a common supertype of ``bytes`` and ``bytearray``.
XXX Should add all their methods.
This ABC is scheduled for removal in Python 3.17.
Use ``isinstance(obj, collections.abc.Buffer)`` to test if ``obj``
implements the buffer protocol at runtime. For use in type annotations,
either use ``Buffer`` or a union that explicitly specifies the types your
code supports (e.g., ``bytes | bytearray | memoryview``).
"""
__slots__ = ()