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

asvetlov webhook-mailer at python.org
Tue Jan 4 03:44:38 EST 2022


https://github.com/python/cpython/commit/5a2a65096c3ec2d37f33615f2a420d2ffcabecf2
commit: 5a2a65096c3ec2d37f33615f2a420d2ffcabecf2
branch: main
author: Nikita Sobolev <mail at sobolevn.me>
committer: asvetlov <andrew.svetlov at gmail.com>
date: 2022-01-04T10:44:26+02:00
summary:

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

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 8c3d73705e3c8..427d4624ad076 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