summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-02-09 16:03:28 +0100
committerVictor Stinner <victor.stinner@gmail.com>2015-02-09 16:03:28 +0100
commit8158d34c1f185303a90f37aed43a1247ad158ed6 (patch)
treef0b308b40c30458875df26c1391e70a819056bc9
parent565d6e7c7e6b2552a61b82799396526365b49fd7 (diff)
downloadtrollius-8158d34c1f185303a90f37aed43a1247ad158ed6.tar.gz
Backout f2ba35e96d46: "Remove unused private function"
coroutines._coroutine_at_yield_from() is used! I just forgot to run tests :-(
-rw-r--r--trollius/coroutines.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/trollius/coroutines.py b/trollius/coroutines.py
index 554ab2d..8f9b998 100644
--- a/trollius/coroutines.py
+++ b/trollius/coroutines.py
@@ -106,6 +106,21 @@ else:
logger.error(fmt, self.value)
+def _coroutine_at_yield_from(coro):
+ """Test if the last instruction of a coroutine is "yield from".
+
+ Return False if the coroutine completed.
+ """
+ frame = coro.gi_frame
+ if frame is None:
+ return False
+ code = coro.gi_code
+ assert frame.f_lasti >= 0
+ offset = frame.f_lasti + 1
+ instr = code.co_code[offset]
+ return (instr == _YIELD_FROM)
+
+
class CoroWrapper(object):
# Wrapper for coroutine object in _DEBUG mode.