[3.14] gh-134657: Remove newly added private names from asyncio.__all__ (GH-134665) (#136455)

gh-134657: Remove newly added private names from asyncio.__all__ (GH-134665)
(cherry picked from commit 797abd1f7f)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-07-09 10:34:19 +02:00 committed by GitHub
parent a9d2f08b57
commit c29fce05f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
47 changed files with 105 additions and 90 deletions

View file

@ -51,15 +51,24 @@ else:
def __getattr__(name: str):
import warnings
deprecated = {
"AbstractEventLoopPolicy",
"DefaultEventLoopPolicy",
"WindowsSelectorEventLoopPolicy",
"WindowsProactorEventLoopPolicy",
}
if name in deprecated:
warnings._deprecated(f"asyncio.{name}", remove=(3, 16))
# deprecated things have underscores in front of them
return globals()["_" + name]
match name:
case "AbstractEventLoopPolicy":
warnings._deprecated(f"asyncio.{name}", remove=(3, 16))
return events._AbstractEventLoopPolicy
case "DefaultEventLoopPolicy":
warnings._deprecated(f"asyncio.{name}", remove=(3, 16))
if sys.platform == 'win32':
return windows_events._DefaultEventLoopPolicy
return unix_events._DefaultEventLoopPolicy
case "WindowsSelectorEventLoopPolicy":
if sys.platform == 'win32':
warnings._deprecated(f"asyncio.{name}", remove=(3, 16))
return windows_events._WindowsSelectorEventLoopPolicy
# Else fall through to the AttributeError below.
case "WindowsProactorEventLoopPolicy":
if sys.platform == 'win32':
warnings._deprecated(f"asyncio.{name}", remove=(3, 16))
return windows_events._WindowsProactorEventLoopPolicy
# Else fall through to the AttributeError below.
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")