-
-
Notifications
You must be signed in to change notification settings - Fork 32.9k
gh-118803: Make ByteString
deprecations louder; remove ByteString
from typing.__all__
and collections.abc.__all__
#139127
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
Merged
AlexWaygood
merged 3 commits into
python:main
from
AlexWaygood:alex/louder-bytestring-deprecation
Sep 18, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
Misc/NEWS.d/next/Library/2025-09-18-14-21-57.gh-issue-118803.2JPbto.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
:class:`collections.abc.ByteString` has been removed from | ||
``collections.abc.__all__``, and :class:`typing.ByteString` has been removed | ||
from ``typing.__all__``. The former has been deprecated since Python 3.12, | ||
and the latter has been deprecated since Python 3.9. Both classes are | ||
scheduled for removal in Python 3.17. | ||
|
||
Additionally, the following statements now cause ``DeprecationWarning``\ s to | ||
be emitted at runtime: ``from collections.abc import ByteString``, ``from | ||
typing import ByteString``, ``import collections.abc; | ||
collections.abc.ByteString`` and ``import typing; typing.ByteString``. Both | ||
classes already caused ``DeprecationWarning``\ s to be emitted if they were | ||
subclassed or used as the second argument to ``isinstance()`` or | ||
``issubclass()``, but they did not previously lead to | ||
``DeprecationWarning``\ s if they were merely imported or accessed from their | ||
respective modules. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means only the first time anyone does
from collections.abc import ByteString
in a program will trigger a warning, right? That seems potentially problematic: maybe the first time is in some dependency you don't control, so you ignore the warning, and then it happens again in your code and you miss it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct. I did that deliberately so that the warning wouldn't be too noisy, and since it's what we previously did for other modules such as
ast
:cpython/Lib/ast.py
Lines 1897 to 1905 in d065edf
But I'm happy to switch to it emitting the deprecation warning even on subsequent imports, if you prefer! It would simplify the implementation a little
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably OK to stick with the standard format here, hopefully it's enough to get people to notice...