summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_dis.py
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2020-11-17 19:30:14 (GMT)
committerGitHub <noreply@github.com>2020-11-17 19:30:14 (GMT)
commit266b462238bddec0213effad3650f19c56511e9f (patch)
treec6547b4075ca52102a61a5ca94d0a7556a07d87c /Lib/test/test_dis.py
parentfa96608513b6eafe48777f1a5504134939dcbebc (diff)
downloadcpython-266b462238bddec0213effad3650f19c56511e9f.zip
cpython-266b462238bddec0213effad3650f19c56511e9f.tar.gz
cpython-266b462238bddec0213effad3650f19c56511e9f.tar.bz2
bpo-42349: Compiler clean up. More yak-shaving for PEP 626. (GH-23267)
Make sure that CFG from compiler front-end is correct. Be a bit more aggressive in the compiler back-end.
Diffstat (limited to 'Lib/test/test_dis.py')
-rw-r--r--Lib/test/test_dis.py49
1 files changed, 25 insertions, 24 deletions
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py
index 216a2df..9cd11d3 100644
--- a/Lib/test/test_dis.py
+++ b/Lib/test/test_dis.py
@@ -145,30 +145,24 @@ def bug1333982(x=[]):
pass
dis_bug1333982 = """\
-%3d 0 LOAD_CONST 1 (0)
- 2 POP_JUMP_IF_TRUE 26
- 4 LOAD_ASSERTION_ERROR
- 6 LOAD_CONST 2 (<code object <listcomp> at 0x..., file "%s", line %d>)
- 8 LOAD_CONST 3 ('bug1333982.<locals>.<listcomp>')
- 10 MAKE_FUNCTION 0
- 12 LOAD_FAST 0 (x)
- 14 GET_ITER
- 16 CALL_FUNCTION 1
-
-%3d 18 LOAD_CONST 4 (1)
-
-%3d 20 BINARY_ADD
- 22 CALL_FUNCTION 1
- 24 RAISE_VARARGS 1
-
-%3d >> 26 LOAD_CONST 0 (None)
- 28 RETURN_VALUE
+%3d 0 LOAD_ASSERTION_ERROR
+ 2 LOAD_CONST 2 (<code object <listcomp> at 0x..., file "%s", line %d>)
+ 4 LOAD_CONST 3 ('bug1333982.<locals>.<listcomp>')
+ 6 MAKE_FUNCTION 0
+ 8 LOAD_FAST 0 (x)
+ 10 GET_ITER
+ 12 CALL_FUNCTION 1
+
+%3d 14 LOAD_CONST 4 (1)
+
+%3d 16 BINARY_ADD
+ 18 CALL_FUNCTION 1
+ 20 RAISE_VARARGS 1
""" % (bug1333982.__code__.co_firstlineno + 1,
__file__,
bug1333982.__code__.co_firstlineno + 1,
bug1333982.__code__.co_firstlineno + 2,
- bug1333982.__code__.co_firstlineno + 1,
- bug1333982.__code__.co_firstlineno + 3)
+ bug1333982.__code__.co_firstlineno + 1)
_BIG_LINENO_FORMAT = """\
%3d 0 LOAD_GLOBAL 0 (spam)
@@ -674,8 +668,15 @@ class DisWithFileTests(DisTests):
return output.getvalue()
+if sys.flags.optimize:
+ code_info_consts = "0: None"
+else:
+ code_info_consts = (
+ """0: 'Formatted details of methods, functions, or code.'
+ 1: None"""
+)
-code_info_code_info = """\
+code_info_code_info = f"""\
Name: code_info
Filename: (.*)
Argument count: 1
@@ -685,13 +686,13 @@ Number of locals: 1
Stack size: 3
Flags: OPTIMIZED, NEWLOCALS, NOFREE
Constants:
- 0: %r
+ {code_info_consts}
Names:
0: _format_code_info
1: _get_code_object
Variable names:
- 0: x""" % (('Formatted details of methods, functions, or code.',)
- if sys.flags.optimize < 2 else (None,))
+ 0: x"""
+
@staticmethod
def tricky(a, b, /, x, y, z=True, *args, c, d, e=[], **kwds):