[Python-checkins] cpython (merge 3.5 -> default): Merge 3.5

yury.selivanov python-checkins at python.org
Fri Nov 20 12:44:25 EST 2015


https://hg.python.org/cpython/rev/4c57c36690a9
changeset: 99238:4c57c36690a9
parent: 99235:76ff3cfef410
parent: 99237:a3f5d053ab24
user: Yury Selivanov <yselivanov at sprymix.com>
date: Fri Nov 20 12:41:53 2015 -0500
summary:
 Merge 3.5
files:
 Lib/asyncio/tasks.py | 22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/Lib/asyncio/tasks.py b/Lib/asyncio/tasks.py
--- a/Lib/asyncio/tasks.py
+++ b/Lib/asyncio/tasks.py
@@ -220,9 +220,9 @@
 self._must_cancel = True
 return True
 
- def _step(self, value=None, exc=None):
+ def _step(self, exc=None):
 assert not self.done(), \
- '_step(): already done: {!r}, {!r}, {!r}'.format(self, value, exc)
+ '_step(): already done: {!r}, {!r}'.format(self, exc)
 if self._must_cancel:
 if not isinstance(exc, futures.CancelledError):
 exc = futures.CancelledError()
@@ -231,12 +231,14 @@
 self._fut_waiter = None
 
 self.__class__._current_tasks[self._loop] = self
- # Call either coro.throw(exc) or coro.send(value).
+ # Call either coro.throw(exc) or coro.send(None).
 try:
- if exc is not None:
+ if exc is None:
+ # We use the `send` method directly, because coroutines
+ # don't have `__iter__` and `__next__` methods.
+ result = coro.send(None)
+ else:
 result = coro.throw(exc)
- else:
- result = coro.send(value)
 except StopIteration as exc:
 self.set_result(exc.value)
 except futures.CancelledError as exc:
@@ -258,7 +260,7 @@
 self._must_cancel = False
 else:
 self._loop.call_soon(
- self._step, None,
+ self._step,
 RuntimeError(
 'yield was used instead of yield from '
 'in task {!r} with {!r}'.format(self, result)))
@@ -268,7 +270,7 @@
 elif inspect.isgenerator(result):
 # Yielding a generator is just wrong.
 self._loop.call_soon(
- self._step, None,
+ self._step,
 RuntimeError(
 'yield was used instead of yield from for '
 'generator in task {!r} with {}'.format(
@@ -276,7 +278,7 @@
 else:
 # Yielding something else is an error.
 self._loop.call_soon(
- self._step, None,
+ self._step,
 RuntimeError(
 'Task got bad yield: {!r}'.format(result)))
 finally:
@@ -288,7 +290,7 @@
 future.result()
 except Exception as exc:
 # This may also be a cancellation.
- self._step(None, exc)
+ self._step(exc)
 else:
 # Don't pass the value of `future.result()` explicitly,
 # as `Future.__iter__` and `Future.__await__` don't need it.
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /