Skip to content

Commit c5c6cda

Browse files
methanemiss-islington
authored andcommitted
asyncio: PendingDeprecationWarning -> DeprecationWarning (GH-12494)
`Task.current_task()` and `Task.all_tasks()` will be removed in 3.9.
1 parent b0df45e commit c5c6cda

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

Lib/asyncio/tasks.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def current_task(cls, loop=None):
9797
"""
9898
warnings.warn("Task.current_task() is deprecated, "
9999
"use asyncio.current_task() instead",
100-
PendingDeprecationWarning,
100+
DeprecationWarning,
101101
stacklevel=2)
102102
if loop is None:
103103
loop = events.get_event_loop()
@@ -111,7 +111,7 @@ def all_tasks(cls, loop=None):
111111
"""
112112
warnings.warn("Task.all_tasks() is deprecated, "
113113
"use asyncio.all_tasks() instead",
114-
PendingDeprecationWarning,
114+
DeprecationWarning,
115115
stacklevel=2)
116116
return _all_tasks_compat(loop)
117117

Lib/test/test_asyncio/test_tasks.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -1634,26 +1634,26 @@ def coro():
16341634
def test_current_task_deprecated(self):
16351635
Task = self.__class__.Task
16361636

1637-
with self.assertWarns(PendingDeprecationWarning):
1637+
with self.assertWarns(DeprecationWarning):
16381638
self.assertIsNone(Task.current_task(loop=self.loop))
16391639

16401640
async def coro(loop):
1641-
with self.assertWarns(PendingDeprecationWarning):
1641+
with self.assertWarns(DeprecationWarning):
16421642
self.assertIs(Task.current_task(loop=loop), task)
16431643

16441644
# See http://bugs.python.org/issue29271 for details:
16451645
asyncio.set_event_loop(loop)
16461646
try:
1647-
with self.assertWarns(PendingDeprecationWarning):
1647+
with self.assertWarns(DeprecationWarning):
16481648
self.assertIs(Task.current_task(None), task)
1649-
with self.assertWarns(PendingDeprecationWarning):
1649+
with self.assertWarns(DeprecationWarning):
16501650
self.assertIs(Task.current_task(), task)
16511651
finally:
16521652
asyncio.set_event_loop(None)
16531653

16541654
task = self.new_task(self.loop, coro(self.loop))
16551655
self.loop.run_until_complete(task)
1656-
with self.assertWarns(PendingDeprecationWarning):
1656+
with self.assertWarns(DeprecationWarning):
16571657
self.assertIsNone(Task.current_task(loop=self.loop))
16581658

16591659
def test_current_task(self):
@@ -1982,7 +1982,7 @@ def test_all_tasks_deprecated(self):
19821982
Task = self.__class__.Task
19831983

19841984
async def coro():
1985-
with self.assertWarns(PendingDeprecationWarning):
1985+
with self.assertWarns(DeprecationWarning):
19861986
assert Task.all_tasks(self.loop) == {t}
19871987

19881988
t = self.new_task(self.loop, coro())
@@ -2012,9 +2012,9 @@ def kill_me(loop):
20122012
# See http://bugs.python.org/issue29271 for details:
20132013
asyncio.set_event_loop(self.loop)
20142014
try:
2015-
with self.assertWarns(PendingDeprecationWarning):
2015+
with self.assertWarns(DeprecationWarning):
20162016
self.assertEqual(Task.all_tasks(), {task})
2017-
with self.assertWarns(PendingDeprecationWarning):
2017+
with self.assertWarns(DeprecationWarning):
20182018
self.assertEqual(Task.all_tasks(None), {task})
20192019
finally:
20202020
asyncio.set_event_loop(None)
@@ -2692,7 +2692,7 @@ def done(self):
26922692
self.assertEqual(asyncio.all_tasks(loop), set())
26932693
self._register_task(task)
26942694
self.assertEqual(asyncio.all_tasks(loop), set())
2695-
with self.assertWarns(PendingDeprecationWarning):
2695+
with self.assertWarns(DeprecationWarning):
26962696
self.assertEqual(asyncio.Task.all_tasks(loop), {task})
26972697
self._unregister_task(task)
26982698

Modules/_asynciomodule.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2088,7 +2088,7 @@ _asyncio_Task_current_task_impl(PyTypeObject *type, PyObject *loop)
20882088
PyObject *ret;
20892089
PyObject *current_task_func;
20902090

2091-
if (PyErr_WarnEx(PyExc_PendingDeprecationWarning,
2091+
if (PyErr_WarnEx(PyExc_DeprecationWarning,
20922092
"Task.current_task() is deprecated, " \
20932093
"use asyncio.current_task() instead",
20942094
1) < 0) {
@@ -2136,7 +2136,7 @@ _asyncio_Task_all_tasks_impl(PyTypeObject *type, PyObject *loop)
21362136
PyObject *res;
21372137
PyObject *all_tasks_func;
21382138

2139-
if (PyErr_WarnEx(PyExc_PendingDeprecationWarning,
2139+
if (PyErr_WarnEx(PyExc_DeprecationWarning,
21402140
"Task.all_tasks() is deprecated, " \
21412141
"use asyncio.all_tasks() instead",
21422142
1) < 0) {

0 commit comments

Comments
 (0)