Skip to content

Conversation

AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented Sep 18, 2025

…tring` from `typing.__all__` and `collections.abc.__all__`
@AlexWaygood AlexWaygood marked this pull request as ready for review September 18, 2025 14:22
@AlexWaygood AlexWaygood added 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section and removed awaiting core review labels Sep 18, 2025
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by @AlexWaygood for commit fc787a5 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F139127%2Fmerge

If you want to schedule another build, you need to add the 🔨 test-with-refleak-buildbots label again.

@bedevere-bot bedevere-bot removed the 🔨 test-with-refleak-buildbots Test PR w/ refleak buildbots; report in status section label Sep 18, 2025
if attr == "ByteString":
import warnings
warnings._deprecated("collections.abc.ByteString", remove=(3, 17))
globals()["ByteString"] = _deprecated_ByteString
Copy link
Member

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.

Copy link
Member Author

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

def __getattr__(name):
if name in _deprecated_globals:
globals()[name] = value = _deprecated_globals[name]
import warnings
warnings._deprecated(
f"ast.{name}", message=_DEPRECATED_CLASS_MESSAGE, remove=(3, 14)
)
return value
raise AttributeError(f"module 'ast' has no attribute '{name}'")

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

Copy link
Member

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...

@AlexWaygood
Copy link
Member Author

The buildbots report a number of reference leaks on this branch, but I can reproduce them all locally on main, and none of them look related to this PR.

@AlexWaygood AlexWaygood enabled auto-merge (squash) September 18, 2025 18:35
@AlexWaygood AlexWaygood merged commit 293b05c into python:main Sep 18, 2025
53 checks passed
@AlexWaygood AlexWaygood deleted the alex/louder-bytestring-deprecation branch September 18, 2025 18:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants