Commit 4271dfd7 authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

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.
parent 3f438a9f
...@@ -677,6 +677,11 @@ Changes in Python behavior ...@@ -677,6 +677,11 @@ Changes in Python behavior
Changes in the Python API Changes in the Python API
------------------------- -------------------------
* :mod:`asyncio`: The module doesn't export :mod:`selectors` and
:mod:`_overlapped` modules as ``asyncio.selectors`` and
``asyncio._overlapped``. Replace ``from asyncio import selectors`` with
``import selectors`` for example.
* :meth:`pkgutil.walk_packages` now raises ValueError if *path* is a string. * :meth:`pkgutil.walk_packages` now raises ValueError if *path* is a string.
Previously an empty list was returned. (Contributed by Sanyam Khurana in Previously an empty list was returned. (Contributed by Sanyam Khurana in
:issue:`24744`.) :issue:`24744`.)
......
...@@ -2,21 +2,6 @@ ...@@ -2,21 +2,6 @@
import sys import sys
# The selectors module is in the stdlib in Python 3.4 but not in 3.3.
# Do this first, so the other submodules can use "from . import selectors".
# Prefer asyncio/selectors.py over the stdlib one, as ours may be newer.
try:
from . import selectors
except ImportError:
import selectors # Will also be exported.
if sys.platform == 'win32':
# Similar thing for _overlapped.
try:
from . import _overlapped
except ImportError:
import _overlapped # Will also be exported.
# This relies on each of the submodules having an __all__ variable. # This relies on each of the submodules having an __all__ variable.
from .base_events import * from .base_events import *
from .coroutines import * from .coroutines import *
......
...@@ -9,6 +9,7 @@ __all__ = ['BaseSelectorEventLoop'] ...@@ -9,6 +9,7 @@ __all__ = ['BaseSelectorEventLoop']
import collections import collections
import errno import errno
import functools import functools
import selectors
import socket import socket
import warnings import warnings
import weakref import weakref
...@@ -21,7 +22,6 @@ from . import base_events ...@@ -21,7 +22,6 @@ from . import base_events
from . import constants from . import constants
from . import events from . import events
from . import futures from . import futures
from . import selectors
from . import transports from . import transports
from . import sslproto from . import sslproto
from .coroutines import coroutine from .coroutines import coroutine
......
...@@ -6,6 +6,7 @@ import io ...@@ -6,6 +6,7 @@ import io
import logging import logging
import os import os
import re import re
import selectors
import socket import socket
import socketserver import socketserver
import sys import sys
...@@ -28,7 +29,6 @@ except ImportError: # pragma: no cover ...@@ -28,7 +29,6 @@ except ImportError: # pragma: no cover
from . import base_events from . import base_events
from . import events from . import events
from . import futures from . import futures
from . import selectors
from . import tasks from . import tasks
from .coroutines import coroutine from .coroutines import coroutine
from .log import logger from .log import logger
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
import errno import errno
import os import os
import selectors
import signal import signal
import socket import socket
import stat import stat
...@@ -18,7 +19,6 @@ from . import coroutines ...@@ -18,7 +19,6 @@ from . import coroutines
from . import events from . import events
from . import futures from . import futures
from . import selector_events from . import selector_events
from . import selectors
from . import transports from . import transports
from .coroutines import coroutine from .coroutines import coroutine
from .log import logger from .log import logger
......
"""Selector and proactor event loops for Windows.""" """Selector and proactor event loops for Windows."""
import _overlapped
import _winapi import _winapi
import errno import errno
import math import math
...@@ -14,7 +15,6 @@ from . import proactor_events ...@@ -14,7 +15,6 @@ from . import proactor_events
from . import selector_events from . import selector_events
from . import tasks from . import tasks
from . import windows_utils from . import windows_utils
from . import _overlapped
from .coroutines import coroutine from .coroutines import coroutine
from .log import logger from .log import logger
......
...@@ -2141,7 +2141,7 @@ if sys.platform == 'win32': ...@@ -2141,7 +2141,7 @@ if sys.platform == 'win32':
def test_remove_fds_after_closing(self): def test_remove_fds_after_closing(self):
raise unittest.SkipTest("IocpEventLoop does not have add_reader()") raise unittest.SkipTest("IocpEventLoop does not have add_reader()")
else: else:
from asyncio import selectors import selectors
class UnixEventLoopTestsMixin(EventLoopTestsMixin): class UnixEventLoopTestsMixin(EventLoopTestsMixin):
def setUp(self): def setUp(self):
......
"""Tests for selector_events.py""" """Tests for selector_events.py"""
import errno import errno
import selectors
import socket import socket
import unittest import unittest
from unittest import mock from unittest import mock
...@@ -10,7 +11,6 @@ except ImportError: ...@@ -10,7 +11,6 @@ except ImportError:
ssl = None ssl = None
import asyncio import asyncio
from asyncio import selectors
from asyncio import test_utils from asyncio import test_utils
from asyncio.selector_events import BaseSelectorEventLoop from asyncio.selector_events import BaseSelectorEventLoop
from asyncio.selector_events import _SelectorTransport from asyncio.selector_events import _SelectorTransport
......
...@@ -7,10 +7,10 @@ from unittest import mock ...@@ -7,10 +7,10 @@ from unittest import mock
if sys.platform != 'win32': if sys.platform != 'win32':
raise unittest.SkipTest('Windows only') raise unittest.SkipTest('Windows only')
import _overlapped
import _winapi import _winapi
import asyncio import asyncio
from asyncio import _overlapped
from asyncio import test_utils from asyncio import test_utils
from asyncio import windows_events from asyncio import windows_events
......
...@@ -9,9 +9,9 @@ from unittest import mock ...@@ -9,9 +9,9 @@ from unittest import mock
if sys.platform != 'win32': if sys.platform != 'win32':
raise unittest.SkipTest('Windows only') raise unittest.SkipTest('Windows only')
import _overlapped
import _winapi import _winapi
from asyncio import _overlapped
from asyncio import windows_utils from asyncio import windows_utils
try: try:
from test import support from test import support
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment