]> granicus.if.org Git - python/commitdiff
asyncio: Drop some useless code from tasks.py.
authorYury Selivanov <yselivanov@sprymix.com>
Thu, 28 May 2015 14:52:19 +0000 (10:52 -0400)
committerYury Selivanov <yselivanov@sprymix.com>
Thu, 28 May 2015 14:52:19 +0000 (10:52 -0400)
See also issue 24017.

Lib/asyncio/tasks.py

index fcb383389ca55f46ac06395ccfaae322df845be9..d8193ba48e1e1e6332bef9b1174a284c31eb5ed8 100644 (file)
@@ -74,10 +74,7 @@ class Task(futures.Future):
         super().__init__(loop=loop)
         if self._source_traceback:
             del self._source_traceback[-1]
-        if coro.__class__ is types.GeneratorType:
-            self._coro = coro
-        else:
-            self._coro = iter(coro)  # Use the iterator just in case.
+        self._coro = coro
         self._fut_waiter = None
         self._must_cancel = False
         self._loop.call_soon(self._step)
@@ -237,10 +234,8 @@ class Task(futures.Future):
         try:
             if exc is not None:
                 result = coro.throw(exc)
-            elif value is not None:
-                result = coro.send(value)
             else:
-                result = coro.send(None)
+                result = coro.send(value)
         except StopIteration as exc:
             self.set_result(exc.value)
         except futures.CancelledError as exc: