summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_pep380.py
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2012-03-15 20:37:39 (GMT)
committerBenjamin Peterson <benjamin@python.org>2012-03-15 20:37:39 (GMT)
commit2afe6aeae820cf2272c6f9be60b185e1c27b734b (patch)
tree806b2e778fa2d90648e9eca16f306769bd804d16 /Lib/test/test_pep380.py
parent3270d11d8aee447e6cbd5388d677b4a23879e80e (diff)
downloadcpython-2afe6aeae820cf2272c6f9be60b185e1c27b734b.zip
cpython-2afe6aeae820cf2272c6f9be60b185e1c27b734b.tar.gz
cpython-2afe6aeae820cf2272c6f9be60b185e1c27b734b.tar.bz2
perform yield from delegation by repeating YIELD_FROM opcode (closes #14230)
This allows generators that are using yield from to be seen by debuggers. It also kills the f_yieldfrom field on frame objects. Patch mostly from Mark Shannon with a few tweaks by me.
Diffstat (limited to 'Lib/test/test_pep380.py')
-rw-r--r--Lib/test/test_pep380.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/Lib/test/test_pep380.py b/Lib/test/test_pep380.py
index bdcfacd..658bcb9 100644
--- a/Lib/test/test_pep380.py
+++ b/Lib/test/test_pep380.py
@@ -10,7 +10,7 @@ see <http://www.cosc.canterbury.ac.nz/greg.ewing/python/yield-from/YieldFrom-Pyt
import unittest
import io
import sys
-import traceback
+import inspect
import parser
from test.support import captured_stderr
@@ -919,6 +919,27 @@ class TestPEP380Operation(unittest.TestCase):
next(g1)
g1.close()
+ def test_delegator_is_visible_to_debugger(self):
+ def call_stack():
+ return [f[3] for f in inspect.stack()]
+
+ def gen():
+ yield call_stack()
+ yield call_stack()
+ yield call_stack()
+
+ def spam(g):
+ yield from g
+
+ def eggs(g):
+ yield from g
+
+ for stack in spam(gen()):
+ self.assertTrue('spam' in stack)
+
+ for stack in spam(eggs(gen())):
+ self.assertTrue('spam' in stack and 'eggs' in stack)
+
def test_main():
from test import support