summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-02-21 11:25:52 (GMT)
committerGitHub <noreply@github.com>2022-02-21 11:25:52 (GMT)
commit195a46d6ffd4cec6c5fb69c5890f8b1758ac91ca (patch)
tree674e5028c65e8dd3b63866774e32405914e3e573
parentbe095f6c32188bba02079d086ac8639ea37cec3c (diff)
downloadcpython-195a46d6ffd4cec6c5fb69c5890f8b1758ac91ca.zip
cpython-195a46d6ffd4cec6c5fb69c5890f8b1758ac91ca.tar.gz
cpython-195a46d6ffd4cec6c5fb69c5890f8b1758ac91ca.tar.bz2
bpo-46796: Simplify handling of removed parameter "loop" in asyncio (GH-31431)
-rw-r--r--Lib/asyncio/locks.py16
-rw-r--r--Lib/asyncio/mixins.py10
-rw-r--r--Lib/asyncio/queues.py3
-rw-r--r--Lib/test/test_asyncio/test_locks.py4
4 files changed, 9 insertions, 24 deletions
diff --git a/Lib/asyncio/locks.py b/Lib/asyncio/locks.py
index 4fef64e..0fbccfa 100644
--- a/Lib/asyncio/locks.py
+++ b/Lib/asyncio/locks.py
@@ -73,8 +73,7 @@ class Lock(_ContextManagerMixin, mixins._LoopBoundMixin):
"""
- def __init__(self, *, loop=mixins._marker):
- super().__init__(loop=loop)
+ def __init__(self):
self._waiters = None
self._locked = False
@@ -163,8 +162,7 @@ class Event(mixins._LoopBoundMixin):
false.
"""
- def __init__(self, *, loop=mixins._marker):
- super().__init__(loop=loop)
+ def __init__(self):
self._waiters = collections.deque()
self._value = False
@@ -226,8 +224,7 @@ class Condition(_ContextManagerMixin, mixins._LoopBoundMixin):
A new Lock object is created and used as the underlying lock.
"""
- def __init__(self, lock=None, *, loop=mixins._marker):
- super().__init__(loop=loop)
+ def __init__(self, lock=None):
if lock is None:
lock = Lock()
@@ -344,8 +341,7 @@ class Semaphore(_ContextManagerMixin, mixins._LoopBoundMixin):
ValueError is raised.
"""
- def __init__(self, value=1, *, loop=mixins._marker):
- super().__init__(loop=loop)
+ def __init__(self, value=1):
if value < 0:
raise ValueError("Semaphore initial value must be >= 0")
self._value = value
@@ -408,9 +404,9 @@ class BoundedSemaphore(Semaphore):
above the initial value.
"""
- def __init__(self, value=1, *, loop=mixins._marker):
+ def __init__(self, value=1):
self._bound_value = value
- super().__init__(value, loop=loop)
+ super().__init__(value)
def release(self):
if self._value >= self._bound_value:
diff --git a/Lib/asyncio/mixins.py b/Lib/asyncio/mixins.py
index 650df05..c6bf973 100644
--- a/Lib/asyncio/mixins.py
+++ b/Lib/asyncio/mixins.py
@@ -5,20 +5,10 @@ from . import events
_global_lock = threading.Lock()
-# Used as a sentinel for loop parameter
-_marker = object()
-
class _LoopBoundMixin:
_loop = None
- def __init__(self, *, loop=_marker):
- if loop is not _marker:
- raise TypeError(
- f'As of 3.10, the *loop* parameter was removed from '
- f'{type(self).__name__}() since it is no longer necessary'
- )
-
def _get_loop(self):
loop = events._get_running_loop()
diff --git a/Lib/asyncio/queues.py b/Lib/asyncio/queues.py
index 10dd689..a9656a6 100644
--- a/Lib/asyncio/queues.py
+++ b/Lib/asyncio/queues.py
@@ -30,8 +30,7 @@ class Queue(mixins._LoopBoundMixin):
interrupted between calling qsize() and doing an operation on the Queue.
"""
- def __init__(self, maxsize=0, *, loop=mixins._marker):
- super().__init__(loop=loop)
+ def __init__(self, maxsize=0):
self._maxsize = maxsize
# Futures.
diff --git a/Lib/test/test_asyncio/test_locks.py b/Lib/test/test_asyncio/test_locks.py
index 4ce3387..d8b164a 100644
--- a/Lib/test/test_asyncio/test_locks.py
+++ b/Lib/test/test_asyncio/test_locks.py
@@ -55,8 +55,8 @@ class LockTests(unittest.IsolatedAsyncioTestCase):
for cls in primitives_cls:
with self.assertRaisesRegex(
TypeError,
- rf'As of 3.10, the \*loop\* parameter was removed from '
- rf'{cls.__name__}\(\) since it is no longer necessary'
+ rf"{cls.__name__}\.__init__\(\) got an unexpected "
+ rf"keyword argument 'loop'"
):
cls(loop=loop)