mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
Issue #21947: handle generator-iterator objects in dis
Patch by Clement Rouault.
This commit is contained in:
parent
d0d64cfb59
commit
efd5df9e52
5 changed files with 26 additions and 10 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue