summaryrefslogtreecommitdiffstats
path: root/Lib/_collections_abc.py
diff options
context:
space:
mode:
authorShantanu <12621235+hauntsaninja@users.noreply.github.com>2023-05-04 16:39:33 (GMT)
committerGitHub <noreply@github.com>2023-05-04 16:39:33 (GMT)
commit09b7695f12f2b44d2df6898407d7e68dd9493ed4 (patch)
treed2446f9106a98a4459dffb53b5a2a4169102d14a /Lib/_collections_abc.py
parent2ba931ff727395cf89b290ed313a8e15db0bfcf1 (diff)
downloadcpython-09b7695f12f2b44d2df6898407d7e68dd9493ed4.zip
cpython-09b7695f12f2b44d2df6898407d7e68dd9493ed4.tar.gz
cpython-09b7695f12f2b44d2df6898407d7e68dd9493ed4.tar.bz2
gh-91896: Deprecate collections.abc.ByteString (#102096)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
Diffstat (limited to 'Lib/_collections_abc.py')
-rw-r--r--Lib/_collections_abc.py23
1 files changed, 21 insertions, 2 deletions
diff --git a/Lib/_collections_abc.py b/Lib/_collections_abc.py
index 2117190..601107d 100644
--- a/Lib/_collections_abc.py
+++ b/Lib/_collections_abc.py
@@ -1071,8 +1071,27 @@ Sequence.register(str)
Sequence.register(range)
Sequence.register(memoryview)
-
-class ByteString(Sequence):
+class _DeprecateByteStringMeta(ABCMeta):
+ def __new__(cls, name, bases, namespace, **kwargs):
+ if name != "ByteString":
+ import warnings
+
+ warnings._deprecated(
+ "collections.abc.ByteString",
+ remove=(3, 14),
+ )
+ return super().__new__(cls, name, bases, namespace, **kwargs)
+
+ def __instancecheck__(cls, instance):
+ import warnings
+
+ warnings._deprecated(
+ "collections.abc.ByteString",
+ remove=(3, 14),
+ )
+ return super().__instancecheck__(instance)
+
+class ByteString(Sequence, metaclass=_DeprecateByteStringMeta):
"""This unifies bytes and bytearray.
XXX Should add all their methods.