summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_dis.py
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2014-07-25 13:02:56 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2014-07-25 13:02:56 (GMT)
commitefd5df9e5267fd337cde95b0dec319ea59187bf4 (patch)
treeaa20c9a774303b891ac047721b8e036e94988578 /Lib/test/test_dis.py
parentd0d64cfb59dda1b82e4ec05160f20316be75760d (diff)
downloadcpython-efd5df9e5267fd337cde95b0dec319ea59187bf4.zip
cpython-efd5df9e5267fd337cde95b0dec319ea59187bf4.tar.gz
cpython-efd5df9e5267fd337cde95b0dec319ea59187bf4.tar.bz2
Issue #21947: handle generator-iterator objects in dis
Patch by Clement Rouault.
Diffstat (limited to 'Lib/test/test_dis.py')
-rw-r--r--Lib/test/test_dis.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py
index d1229fb..f04f12c 100644
--- a/Lib/test/test_dis.py
+++ b/Lib/test/test_dis.py
@@ -229,6 +229,9 @@ dis_traceback = """\
TRACEBACK_CODE.co_firstlineno + 4,
TRACEBACK_CODE.co_firstlineno + 5)
+def _g(x):
+ yield x
+
class DisTests(unittest.TestCase):
def get_disassembly(self, func, lasti=-1, wrapper=True):
@@ -314,6 +317,11 @@ class DisTests(unittest.TestCase):
method_bytecode = _C(1).__init__.__code__.co_code
self.do_disassembly_test(method_bytecode, dis_c_instance_method_bytes)
+ def test_disassemble_generator(self):
+ gen_func_disas = self.get_disassembly(_g) # Disassemble generator function
+ gen_disas = self.get_disassembly(_g(1)) # Disassemble generator itself
+ self.assertEqual(gen_disas, gen_func_disas)
+
def test_dis_none(self):
try:
del sys.last_traceback