Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4271dfd

Browse files
authored
bpo-32154: Remove asyncio.selectors (#4605)
* Remove asyncio.selectors and asyncio._overlapped symbols from the namespace of the asyncio module * Replace "from asyncio import selectors" with "import selectors" * Replace "from asyncio import _overlapped" with "import _overlapped" asyncio.selectors was added to support Python 3.3, which doesn't have selectors in its standard library, and Python 3.4 in the same code base. Same rationale for asyncio._overlapped. Python 3.3 reached its end of life, and asyncio is no more maintained as a third party module on PyPI.
1 parent 3f438a9 commit 4271dfd

10 files changed

Lines changed: 13 additions & 23 deletions

File tree

Doc/whatsnew/3.7.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,11 @@ Changes in Python behavior
677677
Changes in the Python API
678678
-------------------------
679679

680+
* :mod:`asyncio`: The module doesn't export :mod:`selectors` and
681+
:mod:`_overlapped` modules as ``asyncio.selectors`` and
682+
``asyncio._overlapped``. Replace ``from asyncio import selectors`` with
683+
``import selectors`` for example.
684+
680685
* :meth:`pkgutil.walk_packages` now raises ValueError if *path* is a string.
681686
Previously an empty list was returned. (Contributed by Sanyam Khurana in
682687
:issue:`24744`.)

Lib/asyncio/__init__.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,6 @@
22

33
import sys
44

5-
# The selectors module is in the stdlib in Python 3.4 but not in 3.3.
6-
# Do this first, so the other submodules can use "from . import selectors".
7-
# Prefer asyncio/selectors.py over the stdlib one, as ours may be newer.
8-
try:
9-
from . import selectors
10-
except ImportError:
11-
import selectors # Will also be exported.
12-
13-
if sys.platform == 'win32':
14-
# Similar thing for _overlapped.
15-
try:
16-
from . import _overlapped
17-
except ImportError:
18-
import _overlapped # Will also be exported.
19-
205
# This relies on each of the submodules having an __all__ variable.
216
from .base_events import *
227
from .coroutines import *

Lib/asyncio/selector_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import collections
1010
import errno
1111
import functools
12+
import selectors
1213
import socket
1314
import warnings
1415
import weakref
@@ -21,7 +22,6 @@
2122
from . import constants
2223
from . import events
2324
from . import futures
24-
from . import selectors
2525
from . import transports
2626
from . import sslproto
2727
from .coroutines import coroutine

Lib/asyncio/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import logging
77
import os
88
import re
9+
import selectors
910
import socket
1011
import socketserver
1112
import sys
@@ -28,7 +29,6 @@
2829
from . import base_events
2930
from . import events
3031
from . import futures
31-
from . import selectors
3232
from . import tasks
3333
from .coroutines import coroutine
3434
from .log import logger

Lib/asyncio/unix_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import errno
44
import os
5+
import selectors
56
import signal
67
import socket
78
import stat
@@ -18,7 +19,6 @@
1819
from . import events
1920
from . import futures
2021
from . import selector_events
21-
from . import selectors
2222
from . import transports
2323
from .coroutines import coroutine
2424
from .log import logger

Lib/asyncio/windows_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Selector and proactor event loops for Windows."""
22

3+
import _overlapped
34
import _winapi
45
import errno
56
import math
@@ -14,7 +15,6 @@
1415
from . import selector_events
1516
from . import tasks
1617
from . import windows_utils
17-
from . import _overlapped
1818
from .coroutines import coroutine
1919
from .log import logger
2020

Lib/test/test_asyncio/test_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2141,7 +2141,7 @@ def test_create_datagram_endpoint(self):
21412141
def test_remove_fds_after_closing(self):
21422142
raise unittest.SkipTest("IocpEventLoop does not have add_reader()")
21432143
else:
2144-
from asyncio import selectors
2144+
import selectors
21452145

21462146
class UnixEventLoopTestsMixin(EventLoopTestsMixin):
21472147
def setUp(self):

Lib/test/test_asyncio/test_selector_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Tests for selector_events.py"""
22

33
import errno
4+
import selectors
45
import socket
56
import unittest
67
from unittest import mock
@@ -10,7 +11,6 @@
1011
ssl = None
1112

1213
import asyncio
13-
from asyncio import selectors
1414
from asyncio import test_utils
1515
from asyncio.selector_events import BaseSelectorEventLoop
1616
from asyncio.selector_events import _SelectorTransport

Lib/test/test_asyncio/test_windows_events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
if sys.platform != 'win32':
88
raise unittest.SkipTest('Windows only')
99

10+
import _overlapped
1011
import _winapi
1112

1213
import asyncio
13-
from asyncio import _overlapped
1414
from asyncio import test_utils
1515
from asyncio import windows_events
1616

Lib/test/test_asyncio/test_windows_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
if sys.platform != 'win32':
1010
raise unittest.SkipTest('Windows only')
1111

12+
import _overlapped
1213
import _winapi
1314

14-
from asyncio import _overlapped
1515
from asyncio import windows_utils
1616
try:
1717
from test import support

0 commit comments

Comments
 (0)