]> granicus.if.org Git - python/commitdiff
bpo-36373: Fix deprecation warnings (GH-15889)
authorAndrew Svetlov <andrew.svetlov@gmail.com>
Wed, 11 Sep 2019 08:20:24 +0000 (11:20 +0300)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 11 Sep 2019 08:20:24 +0000 (01:20 -0700)
https://bugs.python.org/issue36373

Lib/asyncio/locks.py
Lib/asyncio/queues.py
Lib/test/test_asyncio/test_locks.py
Lib/test/test_asyncio/test_queues.py
Lib/unittest/async_case.py

index f63d4cedbbb7c3e32bc2c348add20eb43f60f26d..d94daeb5a173f574f8509a366f1bcb9337e487ba 100644 (file)
@@ -332,7 +332,7 @@ class Condition(_ContextManagerMixin):
                           DeprecationWarning, stacklevel=2)
 
         if lock is None:
-            lock = Lock(loop=self._loop)
+            lock = Lock(loop=loop)
         elif lock._loop is not self._loop:
             raise ValueError("loop argument must agree with lock")
 
index c96b4a0c1ba3274a953ac1c7e6614900d2257bd2..390ae9a6821c4d4e3790458c1d5615f396b4fa14 100644 (file)
@@ -45,7 +45,7 @@ class Queue:
         # Futures.
         self._putters = collections.deque()
         self._unfinished_tasks = 0
-        self._finished = locks.Event(loop=self._loop)
+        self._finished = locks.Event(loop=loop)
         self._finished.set()
         self._init(maxsize)
 
index d69b56dcda2254681d18ba2217f8a72a241b31a8..a9953b4b2a2de24ba7d23c42ed8cdbac87f69819 100644 (file)
@@ -500,10 +500,9 @@ class ConditionTests(test_utils.TestCase):
             self.assertIs(cond._loop, self.loop)
 
     def test_ctor_noloop(self):
-        with self.assertWarns(DeprecationWarning):
-            asyncio.set_event_loop(self.loop)
-            cond = asyncio.Condition()
-            self.assertIs(cond._loop, self.loop)
+        asyncio.set_event_loop(self.loop)
+        cond = asyncio.Condition()
+        self.assertIs(cond._loop, self.loop)
 
     def test_wait(self):
         with self.assertWarns(DeprecationWarning):
index 02e8e43ccee6987db59421a8372ffc8d2445178c..171176c9fc5309559957e8c7f577918dac9d62d5 100644 (file)
@@ -83,8 +83,7 @@ class QueueBasicTests(_QueueTestBase):
 
     def test_ctor_noloop(self):
         asyncio.set_event_loop(self.loop)
-        with self.assertWarns(DeprecationWarning):
-            q = asyncio.Queue()
+        q = asyncio.Queue()
         self.assertIs(q._loop, self.loop)
 
     def test_repr(self):
index a3c8bfb9eca758009651cc199ab6a6a88f752044..1bc1312c8c2ee9cba2491d66a44b157a37c3ab9e 100644 (file)
@@ -89,8 +89,9 @@ class IsolatedAsyncioTestCase(TestCase):
         else:
             return ret
 
-    async def _asyncioLoopRunner(self):
-        queue = self._asyncioCallsQueue
+    async def _asyncioLoopRunner(self, fut):
+        self._asyncioCallsQueue = queue = asyncio.Queue()
+        fut.set_result(None)
         while True:
             query = await queue.get()
             queue.task_done()
@@ -113,8 +114,9 @@ class IsolatedAsyncioTestCase(TestCase):
         asyncio.set_event_loop(loop)
         loop.set_debug(True)
         self._asyncioTestLoop = loop
-        self._asyncioCallsQueue = asyncio.Queue(loop=loop)
-        self._asyncioCallsTask = loop.create_task(self._asyncioLoopRunner())
+        fut = loop.create_future()
+        self._asyncioCallsTask = loop.create_task(self._asyncioLoopRunner(fut))
+        loop.run_until_complete(fut)
 
     def _tearDownAsyncioLoop(self):
         assert self._asyncioTestLoop is not None