mirror of
https://github.com/python/cpython.git
synced 2025-07-23 03:05:38 +00:00
GH-90985: Revert "Deprecate passing a message into cancel()" (GH-97999)
Reason: we were too hasty in deprecating this.
We shouldn't deprecate it before we have a replacement.
(cherry picked from commit 09de8d7aaf
)
Co-authored-by: Guido van Rossum <guido@python.org>
This commit is contained in:
parent
c9d0a7a6bc
commit
d163d5976d
8 changed files with 12 additions and 102 deletions
|
@ -113,11 +113,7 @@ class BaseTaskTests:
|
|||
self.assertTrue(hasattr(t, '_cancel_message'))
|
||||
self.assertEqual(t._cancel_message, None)
|
||||
|
||||
with self.assertWarnsRegex(
|
||||
DeprecationWarning,
|
||||
"Passing 'msg' argument"
|
||||
):
|
||||
t.cancel('my message')
|
||||
t.cancel('my message')
|
||||
self.assertEqual(t._cancel_message, 'my message')
|
||||
|
||||
with self.assertRaises(asyncio.CancelledError) as cm:
|
||||
|
@ -129,11 +125,7 @@ class BaseTaskTests:
|
|||
async def coro():
|
||||
pass
|
||||
t = self.new_task(self.loop, coro())
|
||||
with self.assertWarnsRegex(
|
||||
DeprecationWarning,
|
||||
"Passing 'msg' argument"
|
||||
):
|
||||
t.cancel('my message')
|
||||
t.cancel('my message')
|
||||
t._cancel_message = 'my new message'
|
||||
self.assertEqual(t._cancel_message, 'my new message')
|
||||
|
||||
|
@ -710,14 +702,7 @@ class BaseTaskTests:
|
|||
async def coro():
|
||||
task = self.new_task(loop, sleep())
|
||||
await asyncio.sleep(0)
|
||||
if cancel_args not in ((), (None,)):
|
||||
with self.assertWarnsRegex(
|
||||
DeprecationWarning,
|
||||
"Passing 'msg' argument"
|
||||
):
|
||||
task.cancel(*cancel_args)
|
||||
else:
|
||||
task.cancel(*cancel_args)
|
||||
task.cancel(*cancel_args)
|
||||
done, pending = await asyncio.wait([task])
|
||||
task.result()
|
||||
|
||||
|
@ -751,14 +736,7 @@ class BaseTaskTests:
|
|||
async def coro():
|
||||
task = self.new_task(loop, sleep())
|
||||
await asyncio.sleep(0)
|
||||
if cancel_args not in ((), (None,)):
|
||||
with self.assertWarnsRegex(
|
||||
DeprecationWarning,
|
||||
"Passing 'msg' argument"
|
||||
):
|
||||
task.cancel(*cancel_args)
|
||||
else:
|
||||
task.cancel(*cancel_args)
|
||||
task.cancel(*cancel_args)
|
||||
done, pending = await asyncio.wait([task])
|
||||
task.exception()
|
||||
|
||||
|
@ -781,17 +759,10 @@ class BaseTaskTests:
|
|||
fut.set_result(None)
|
||||
await asyncio.sleep(10)
|
||||
|
||||
def cancel(task, msg):
|
||||
with self.assertWarnsRegex(
|
||||
DeprecationWarning,
|
||||
"Passing 'msg' argument"
|
||||
):
|
||||
task.cancel(msg)
|
||||
|
||||
async def coro():
|
||||
inner_task = self.new_task(loop, sleep())
|
||||
await fut
|
||||
loop.call_soon(cancel, inner_task, 'msg')
|
||||
loop.call_soon(inner_task.cancel, 'msg')
|
||||
try:
|
||||
await inner_task
|
||||
except asyncio.CancelledError as ex:
|
||||
|
@ -817,11 +788,7 @@ class BaseTaskTests:
|
|||
async def coro():
|
||||
task = self.new_task(loop, sleep())
|
||||
# We deliberately leave out the sleep here.
|
||||
with self.assertWarnsRegex(
|
||||
DeprecationWarning,
|
||||
"Passing 'msg' argument"
|
||||
):
|
||||
task.cancel('my message')
|
||||
task.cancel('my message')
|
||||
done, pending = await asyncio.wait([task])
|
||||
task.exception()
|
||||
|
||||
|
@ -2183,14 +2150,7 @@ class BaseTaskTests:
|
|||
async def main():
|
||||
qwe = self.new_task(loop, test())
|
||||
await asyncio.sleep(0.2)
|
||||
if cancel_args not in ((), (None,)):
|
||||
with self.assertWarnsRegex(
|
||||
DeprecationWarning,
|
||||
"Passing 'msg' argument"
|
||||
):
|
||||
qwe.cancel(*cancel_args)
|
||||
else:
|
||||
qwe.cancel(*cancel_args)
|
||||
qwe.cancel(*cancel_args)
|
||||
await qwe
|
||||
|
||||
try:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue