Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 33.9k
gh-91896: Deprecate collections.abc.ByteString#102096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
804dfa14c7eaced534015476a25946404a0b1b4fd2dc22a74eeaff448777d29c0537774523ef0c23e1adf774692File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -273,6 +273,12 @@ Collections Abstract Base Classes -- Detailed Descriptions | ||
| The index() method added support for *stop* and *start* | ||
| arguments. | ||
| .. deprecated-removed:: 3.12 3.14 | ||
| The :class:`ByteString` ABC has been deprecated. | ||
| For use in typing, prefer a union, like ``bytes | bytearray``, or | ||
| :class:`collections.abc.Buffer`. | ||
hauntsaninja marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| For use as an ABC, prefer :class:`Sequence` or :class:`collections.abc.Buffer`. | ||
| .. class:: Set | ||
| MutableSet | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -792,6 +792,11 @@ Pending Removal in Python 3.14 | ||
| (Contributed by Jason R. Coombs and Hugo van Kemenade in :gh:`93963`.) | ||
| * Deprecated :class:`collections.abc.ByteString`. | ||
| Prefer :class:`Sequence` or :class:`collections.abc.Buffer`. | ||
hugovk marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| For use in typing, prefer a union, like ``bytes | bytearray``, or :class:`collections.abc.Buffer`. | ||
| (Contributed by Shantanu Jain in :gh:`91896`.) | ||
| * Creating immutable types (:data:`Py_TPFLAGS_IMMUTABLETYPE`) with mutable | ||
| bases using the C API. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1071,8 +1071,27 @@ def count(self, value): | ||
| 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( | ||
hauntsaninja marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| "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): | ||
hauntsaninja marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
| """This unifies bytes and bytearray. | ||
| XXX Should add all their methods. | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can also remove this comment. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Deprecate :class:`collections.abc.ByteString` | ||
hugovk marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. | ||
Uh oh!
There was an error while loading. Please reload this page.