diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-08 09:34:25 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-08 09:34:25 (GMT) |
commit | dd102f7af8bc319205e7efd726af48d50a5ac103 (patch) | |
tree | d5feac621292f0f9e773b9e91b264dcde5e16e88 /Lib/test/test_dis.py | |
parent | 56588b7055a3c503bb7226a41d10be47f4bf2d58 (diff) | |
download | cpython-dd102f7af8bc319205e7efd726af48d50a5ac103.zip cpython-dd102f7af8bc319205e7efd726af48d50a5ac103.tar.gz cpython-dd102f7af8bc319205e7efd726af48d50a5ac103.tar.bz2 |
Issue #28317: The disassembler now decodes FORMAT_VALUE argument.
Diffstat (limited to 'Lib/test/test_dis.py')
-rw-r--r-- | Lib/test/test_dis.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py index f319336..b9b5ac2 100644 --- a/Lib/test/test_dis.py +++ b/Lib/test/test_dis.py @@ -301,6 +301,27 @@ dis_traceback = """\ TRACEBACK_CODE.co_firstlineno + 4, TRACEBACK_CODE.co_firstlineno + 5) +def _fstring(a, b, c, d): + return f'{a} {b:4} {c!r} {d!r:4}' + +dis_fstring = """\ +%3d 0 LOAD_FAST 0 (a) + 2 FORMAT_VALUE 0 + 4 LOAD_CONST 1 (' ') + 6 LOAD_FAST 1 (b) + 8 LOAD_CONST 2 ('4') + 10 FORMAT_VALUE 4 (with format) + 12 LOAD_CONST 1 (' ') + 14 LOAD_FAST 2 (c) + 16 FORMAT_VALUE 2 (repr) + 18 LOAD_CONST 1 (' ') + 20 LOAD_FAST 3 (d) + 22 LOAD_CONST 2 ('4') + 24 FORMAT_VALUE 6 (repr, with format) + 26 BUILD_STRING 7 + 28 RETURN_VALUE +""" % (_fstring.__code__.co_firstlineno + 1,) + def _g(x): yield x @@ -404,6 +425,9 @@ class DisTests(unittest.TestCase): gen_disas = self.get_disassembly(_g(1)) # Disassemble generator itself self.assertEqual(gen_disas, gen_func_disas) + def test_disassemble_fstring(self): + self.do_disassembly_test(_fstring, dis_fstring) + def test_dis_none(self): try: del sys.last_traceback |