[New-bugs-announce] [issue46239] Incosistent error message in asyncio: windows_events / windows_utils

Nikita Sobolev report at bugs.python.org
Mon Jan 3 04:58:19 EST 2022


New submission from Nikita Sobolev <mail at sobolevn.me>:

When trying to import both `windows_events` and `windows_utils` on non-Windows, they both fail.

But, they fail differently. `windows_utils` produces a good error message, whil `windows_events` produces a strange one.

Good:

```
Python 3.11.0a3+ (heads/main:8d7644fa64, Dec 30 2021, 13:00:40) [Clang 11.0.0 (clang-1100.0.33.16)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import asyncio.windows_utils
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/sobolev/Desktop/cpython/Lib/asyncio/windows_utils.py", line 6, in <module>
    raise ImportError('win32 only')
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: win32 only
```

Not so good:

```
>>> 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'
```

I propose to use the same error message `windows_utils` does.

----------
components: asyncio
messages: 409571
nosy: asvetlov, sobolevn, yselivanov
priority: normal
severity: normal
status: open
title: Incosistent error message in asyncio: windows_events / windows_utils
type: behavior
versions: Python 3.10, Python 3.11, Python 3.9

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46239>
_______________________________________


More information about the New-bugs-announce mailing list