]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
asyncio: PendingDeprecationWarning -> DeprecationWarning (GH-12494)
authorInada Naoki <songofacandy@gmail.com>
Fri, 22 Mar 2019 11:07:32 +0000 (20:07 +0900)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 22 Mar 2019 11:07:32 +0000 (04:07 -0700)
`Task.current_task()` and `Task.all_tasks()` will be removed in 3.9.

Lib/asyncio/tasks.py
Lib/test/test_asyncio/test_tasks.py
Modules/_asynciomodule.c

index 15422da1b3b2e0015c6cd5a33278f4ba5f824ca7..d8508376d92a48ffeee43e0d291e8485817aa386 100644 (file)
@@ -97,7 +97,7 @@ class Task(futures._PyFuture):  # Inherit Python Task implementation
         """
         warnings.warn("Task.current_task() is deprecated, "
                       "use asyncio.current_task() instead",
-                      PendingDeprecationWarning,
+                      DeprecationWarning,
                       stacklevel=2)
         if loop is None:
             loop = events.get_event_loop()
@@ -111,7 +111,7 @@ class Task(futures._PyFuture):  # Inherit Python Task implementation
         """
         warnings.warn("Task.all_tasks() is deprecated, "
                       "use asyncio.all_tasks() instead",
-                      PendingDeprecationWarning,
+                      DeprecationWarning,
                       stacklevel=2)
         return _all_tasks_compat(loop)
 
index 22f14f87624e891b0dde42a48acaed7788ce977c..1cdff528def49d5d5152b1f50d54b7f7e0d5b7a1 100644 (file)
@@ -1634,26 +1634,26 @@ class BaseTaskTests:
     def test_current_task_deprecated(self):
         Task = self.__class__.Task
 
-        with self.assertWarns(PendingDeprecationWarning):
+        with self.assertWarns(DeprecationWarning):
             self.assertIsNone(Task.current_task(loop=self.loop))
 
         async def coro(loop):
-            with self.assertWarns(PendingDeprecationWarning):
+            with self.assertWarns(DeprecationWarning):
                 self.assertIs(Task.current_task(loop=loop), task)
 
             # See http://bugs.python.org/issue29271 for details:
             asyncio.set_event_loop(loop)
             try:
-                with self.assertWarns(PendingDeprecationWarning):
+                with self.assertWarns(DeprecationWarning):
                     self.assertIs(Task.current_task(None), task)
-                with self.assertWarns(PendingDeprecationWarning):
+                with self.assertWarns(DeprecationWarning):
                     self.assertIs(Task.current_task(), task)
             finally:
                 asyncio.set_event_loop(None)
 
         task = self.new_task(self.loop, coro(self.loop))
         self.loop.run_until_complete(task)
-        with self.assertWarns(PendingDeprecationWarning):
+        with self.assertWarns(DeprecationWarning):
             self.assertIsNone(Task.current_task(loop=self.loop))
 
     def test_current_task(self):
@@ -1982,7 +1982,7 @@ class BaseTaskTests:
         Task = self.__class__.Task
 
         async def coro():
-            with self.assertWarns(PendingDeprecationWarning):
+            with self.assertWarns(DeprecationWarning):
                 assert Task.all_tasks(self.loop) == {t}
 
         t = self.new_task(self.loop, coro())
@@ -2012,9 +2012,9 @@ class BaseTaskTests:
         # See http://bugs.python.org/issue29271 for details:
         asyncio.set_event_loop(self.loop)
         try:
-            with self.assertWarns(PendingDeprecationWarning):
+            with self.assertWarns(DeprecationWarning):
                 self.assertEqual(Task.all_tasks(), {task})
-            with self.assertWarns(PendingDeprecationWarning):
+            with self.assertWarns(DeprecationWarning):
                 self.assertEqual(Task.all_tasks(None), {task})
         finally:
             asyncio.set_event_loop(None)
@@ -2692,7 +2692,7 @@ class BaseTaskIntrospectionTests:
         self.assertEqual(asyncio.all_tasks(loop), set())
         self._register_task(task)
         self.assertEqual(asyncio.all_tasks(loop), set())
-        with self.assertWarns(PendingDeprecationWarning):
+        with self.assertWarns(DeprecationWarning):
             self.assertEqual(asyncio.Task.all_tasks(loop), {task})
         self._unregister_task(task)
 
index 7637cb75d63f196208d8a2285b61b909bcb7be59..f9037c279ac9c34b8679ffbbbc4d1750ce3670bf 100644 (file)
@@ -2088,7 +2088,7 @@ _asyncio_Task_current_task_impl(PyTypeObject *type, PyObject *loop)
     PyObject *ret;
     PyObject *current_task_func;
 
-    if (PyErr_WarnEx(PyExc_PendingDeprecationWarning,
+    if (PyErr_WarnEx(PyExc_DeprecationWarning,
                      "Task.current_task() is deprecated, " \
                      "use asyncio.current_task() instead",
                      1) < 0) {
@@ -2136,7 +2136,7 @@ _asyncio_Task_all_tasks_impl(PyTypeObject *type, PyObject *loop)
     PyObject *res;
     PyObject *all_tasks_func;
 
-    if (PyErr_WarnEx(PyExc_PendingDeprecationWarning,
+    if (PyErr_WarnEx(PyExc_DeprecationWarning,
                      "Task.all_tasks() is deprecated, " \
                      "use asyncio.all_tasks() instead",
                      1) < 0) {