From b0bf9ccb3fc881232e5284b06338f9263f3135b1 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Mon, 3 Jan 2022 12:59:55 +0300 Subject: [PATCH] bpo-46239: improve error message when importing `asyncio.windows_events` --- Lib/asyncio/windows_events.py | 5 +++++ .../next/Library/2022-01-03-12-59-20.bpo-46239.ySVSEy.rst | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2022-01-03-12-59-20.bpo-46239.ySVSEy.rst diff --git a/Lib/asyncio/windows_events.py b/Lib/asyncio/windows_events.py index 5e7cd795895d65..da81ab435b9a6f 100644 --- a/Lib/asyncio/windows_events.py +++ b/Lib/asyncio/windows_events.py @@ -1,5 +1,10 @@ """Selector and proactor event loops for Windows.""" +import sys + +if sys.platform != 'win32': # pragma: no cover + raise ImportError('win32 only') + import _overlapped import _winapi import errno diff --git a/Misc/NEWS.d/next/Library/2022-01-03-12-59-20.bpo-46239.ySVSEy.rst b/Misc/NEWS.d/next/Library/2022-01-03-12-59-20.bpo-46239.ySVSEy.rst new file mode 100644 index 00000000000000..202febf84fd109 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-01-03-12-59-20.bpo-46239.ySVSEy.rst @@ -0,0 +1,2 @@ +Improve error message when importing :mod:`asyncio.windows_events` on +non-Windows.