Skip to content

Commit 195a46d

Browse files
bpo-46796: Simplify handling of removed parameter "loop" in asyncio (pythonGH-31431)
1 parent be095f6 commit 195a46d

File tree

4 files changed

+9
-24
lines changed

4 files changed

+9
-24
lines changed

Lib/asyncio/locks.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ class Lock(_ContextManagerMixin, mixins._LoopBoundMixin):
7373
7474
"""
7575

76-
def __init__(self, *, loop=mixins._marker):
77-
super().__init__(loop=loop)
76+
def __init__(self):
7877
self._waiters = None
7978
self._locked = False
8079

@@ -163,8 +162,7 @@ class Event(mixins._LoopBoundMixin):
163162
false.
164163
"""
165164

166-
def __init__(self, *, loop=mixins._marker):
167-
super().__init__(loop=loop)
165+
def __init__(self):
168166
self._waiters = collections.deque()
169167
self._value = False
170168

@@ -226,8 +224,7 @@ class Condition(_ContextManagerMixin, mixins._LoopBoundMixin):
226224
A new Lock object is created and used as the underlying lock.
227225
"""
228226

229-
def __init__(self, lock=None, *, loop=mixins._marker):
230-
super().__init__(loop=loop)
227+
def __init__(self, lock=None):
231228
if lock is None:
232229
lock = Lock()
233230

@@ -344,8 +341,7 @@ class Semaphore(_ContextManagerMixin, mixins._LoopBoundMixin):
344341
ValueError is raised.
345342
"""
346343

347-
def __init__(self, value=1, *, loop=mixins._marker):
348-
super().__init__(loop=loop)
344+
def __init__(self, value=1):
349345
if value < 0:
350346
raise ValueError("Semaphore initial value must be >= 0")
351347
self._value = value
@@ -408,9 +404,9 @@ class BoundedSemaphore(Semaphore):
408404
above the initial value.
409405
"""
410406

411-
def __init__(self, value=1, *, loop=mixins._marker):
407+
def __init__(self, value=1):
412408
self._bound_value = value
413-
super().__init__(value, loop=loop)
409+
super().__init__(value)
414410

415411
def release(self):
416412
if self._value >= self._bound_value:

Lib/asyncio/mixins.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,10 @@
55

66
_global_lock = threading.Lock()
77

8-
# Used as a sentinel for loop parameter
9-
_marker = object()
10-
118

129
class _LoopBoundMixin:
1310
_loop = None
1411

15-
def __init__(self, *, loop=_marker):
16-
if loop is not _marker:
17-
raise TypeError(
18-
f'As of 3.10, the *loop* parameter was removed from '
19-
f'{type(self).__name__}() since it is no longer necessary'
20-
)
21-
2212
def _get_loop(self):
2313
loop = events._get_running_loop()
2414

Lib/asyncio/queues.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ class Queue(mixins._LoopBoundMixin):
3030
interrupted between calling qsize() and doing an operation on the Queue.
3131
"""
3232

33-
def __init__(self, maxsize=0, *, loop=mixins._marker):
34-
super().__init__(loop=loop)
33+
def __init__(self, maxsize=0):
3534
self._maxsize = maxsize
3635

3736
# Futures.

Lib/test/test_asyncio/test_locks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ async def test_lock_doesnt_accept_loop_parameter(self):
5555
for cls in primitives_cls:
5656
with self.assertRaisesRegex(
5757
TypeError,
58-
rf'As of 3.10, the \*loop\* parameter was removed from '
59-
rf'{cls.__name__}\(\) since it is no longer necessary'
58+
rf"{cls.__name__}\.__init__\(\) got an unexpected "
59+
rf"keyword argument 'loop'"
6060
):
6161
cls(loop=loop)
6262

0 commit comments

Comments
 (0)