[Python-checkins] bpo-46239: improve error message when importing `asyncio.windows_events` (GH-30353) (#30388)

asvetlov webhook-mailer at python.org
Tue Jan 4 04:22:47 EST 2022


https://github.com/python/cpython/commit/cf48a148190a6ccadc144cab2e2046e95c20fb57
commit: cf48a148190a6ccadc144cab2e2046e95c20fb57
branch: 3.10
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: asvetlov <andrew.svetlov at gmail.com>
date: 2022-01-04T11:22:26+02:00
summary:

bpo-46239: improve error message when importing `asyncio.windows_events` (GH-30353) (#30388)

(cherry picked from commit 5a2a65096c3ec2d37f33615f2a420d2ffcabecf2)

Co-authored-by: Nikita Sobolev <mail at sobolevn.me>

Co-authored-by: Nikita Sobolev <mail at sobolevn.me>

files:
A Misc/NEWS.d/next/Library/2022-01-03-12-59-20.bpo-46239.ySVSEy.rst
M Lib/asyncio/windows_events.py

diff --git a/Lib/asyncio/windows_events.py b/Lib/asyncio/windows_events.py
index 5e7cd795895d6..da81ab435b9a6 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 0000000000000..202febf84fd10
--- /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.



More information about the Python-checkins mailing list