Skip to content

bpo-46239: improve error message when importing asyncio.windows_events#30353

Merged
asvetlov merged 1 commit into
python:mainfrom
sobolevn:issue-46239
Jan 4, 2022
Merged

bpo-46239: improve error message when importing asyncio.windows_events#30353
asvetlov merged 1 commit into
python:mainfrom
sobolevn:issue-46239

Conversation

@sobolevn

@sobolevn sobolevn commented Jan 3, 2022

Copy link
Copy Markdown
Member

This module is Win-only, importing it on non-Win platform used to raise quite cryptic error message.

Used to be:

>>> import asyncio.windows_events
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/sobolev/Desktop/cpython/Lib/asyncio/windows_events.py", line 3, in <module>
    import _overlapped
    ^^^^^^^^^^^^^^^^^^
ModuleNotFoundError: No module named '_overlapped'

Now:

>>> import asyncio.windows_events
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/sobolev/Desktop/cpython/Lib/asyncio/windows_events.py", line 6, in <module>
    raise ImportError('win32 only')
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: win32 only

It is now in sync with

if sys.platform != 'win32': # pragma: no cover
raise ImportError('win32 only')

https://bugs.python.org/issue46239

@asvetlov

asvetlov commented Jan 4, 2022

Copy link
Copy Markdown
Contributor

Thanks!

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @sobolevn for the PR, and @asvetlov for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒⛏🤖

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @sobolevn for the PR, and @asvetlov for merging it 🌮🎉.. I'm working now to backport this PR to: 3.9.
🐍🍒⛏🤖

@bedevere-bot

Copy link
Copy Markdown

GH-30388 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Jan 4, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 4, 2022
…ts` (pythonGH-30353)

(cherry picked from commit 5a2a650)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
@bedevere-bot

Copy link
Copy Markdown

GH-30389 is a backport of this pull request to the 3.9 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jan 4, 2022
…ts` (pythonGH-30353)

(cherry picked from commit 5a2a650)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
miss-islington added a commit that referenced this pull request Jan 4, 2022
…ts` (GH-30353)

(cherry picked from commit 5a2a650)

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
asvetlov pushed a commit that referenced this pull request Jan 4, 2022
…ts` (GH-30353) (#30388)

(cherry picked from commit 5a2a650)

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

Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants