mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
gh-118803: Remove ByteString from typing and collections.abc (#118804)
This commit is contained in:
parent
cb6f75a32c
commit
2f4db5a04d
12 changed files with 14 additions and 114 deletions
|
|
@ -49,7 +49,7 @@ __all__ = ["Awaitable", "Coroutine",
|
|||
"Mapping", "MutableMapping",
|
||||
"MappingView", "KeysView", "ItemsView", "ValuesView",
|
||||
"Sequence", "MutableSequence",
|
||||
"ByteString", "Buffer",
|
||||
"Buffer",
|
||||
]
|
||||
|
||||
# This module has been renamed from collections.abc to _collections_abc to
|
||||
|
|
@ -1068,40 +1068,10 @@ class Sequence(Reversible, Collection):
|
|||
|
||||
Sequence.register(tuple)
|
||||
Sequence.register(str)
|
||||
Sequence.register(bytes)
|
||||
Sequence.register(range)
|
||||
Sequence.register(memoryview)
|
||||
|
||||
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.
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
|
||||
ByteString.register(bytes)
|
||||
ByteString.register(bytearray)
|
||||
|
||||
|
||||
class MutableSequence(Sequence):
|
||||
"""All the operations on a read-write sequence.
|
||||
|
|
@ -1170,4 +1140,4 @@ class MutableSequence(Sequence):
|
|||
|
||||
|
||||
MutableSequence.register(list)
|
||||
MutableSequence.register(bytearray) # Multiply inheriting, see ByteString
|
||||
MutableSequence.register(bytearray)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue