aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Lib/asyncio/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/asyncio/__init__.py')
-rw-r--r--Lib/asyncio/__init__.py29
1 files changed, 19 insertions, 10 deletions
diff --git a/Lib/asyncio/__init__.py b/Lib/asyncio/__init__.py
index 4be7112fa01..32a5dbae03a 100644
--- a/Lib/asyncio/__init__.py
+++ b/Lib/asyncio/__init__.py
@@ -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}")