]> granicus.if.org Git - python/commitdiff
bpo-36373: Deprecate explicit loop parameter in all public asyncio APIs [streams...
authorEmmanuel Arias <emmanuelarias30@gmail.com>
Wed, 5 Jun 2019 05:45:53 +0000 (02:45 -0300)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 5 Jun 2019 05:45:53 +0000 (22:45 -0700)
This PR deprecate explicit loop parameters in all public asyncio APIs

This issues is split to be easier to review.

Second step: streams.py

https://bugs.python.org/issue36373

Lib/asyncio/streams.py

index 480f1a3fdd74edce0a518daf19e5f5e2e5027595..f03441b6b11ded77d5976fc859294c75881a5112 100644 (file)
@@ -175,6 +175,10 @@ async def open_connection(host=None, port=None, *,
                   stacklevel=2)
     if loop is None:
         loop = events.get_event_loop()
+    else:
+        warnings.warn("The loop argument is deprecated since Python 3.8, "
+                      "and scheduled for removal in Python 3.10.",
+                      DeprecationWarning, stacklevel=2)
     reader = StreamReader(limit=limit, loop=loop)
     protocol = StreamReaderProtocol(reader, loop=loop, _asyncio_internal=True)
     transport, _ = await loop.create_connection(
@@ -213,6 +217,10 @@ async def start_server(client_connected_cb, host=None, port=None, *,
                   stacklevel=2)
     if loop is None:
         loop = events.get_event_loop()
+    else:
+        warnings.warn("The loop argument is deprecated since Python 3.8, "
+                      "and scheduled for removal in Python 3.10.",
+                      DeprecationWarning, stacklevel=2)
 
     def factory():
         reader = StreamReader(limit=limit, loop=loop)
@@ -414,6 +422,10 @@ if hasattr(socket, 'AF_UNIX'):
                       stacklevel=2)
         if loop is None:
             loop = events.get_event_loop()
+        else:
+            warnings.warn("The loop argument is deprecated since Python 3.8, "
+                          "and scheduled for removal in Python 3.10.",
+                          DeprecationWarning, stacklevel=2)
         reader = StreamReader(limit=limit, loop=loop)
         protocol = StreamReaderProtocol(reader, loop=loop,
                                         _asyncio_internal=True)
@@ -473,6 +485,10 @@ if hasattr(socket, 'AF_UNIX'):
                       stacklevel=2)
         if loop is None:
             loop = events.get_event_loop()
+        else:
+            warnings.warn("The loop argument is deprecated since Python 3.8, "
+                          "and scheduled for removal in Python 3.10.",
+                          DeprecationWarning, stacklevel=2)
 
         def factory():
             reader = StreamReader(limit=limit, loop=loop)