Skip to content

Commit aa99c05

Browse files
authored
Merge pull request #6870 from ShaharNaveh/update-dis-3-14-2
2 parents 364ddaa + 253414f commit aa99c05

File tree

3 files changed

+1740
-184
lines changed

3 files changed

+1740
-184
lines changed

Lib/test/test_compiler_assemble.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def inner():
8484
return x
8585
return inner() % 2
8686

87-
inner_code = mod_two.__code__.co_consts[1]
87+
inner_code = mod_two.__code__.co_consts[0]
8888
assert isinstance(inner_code, types.CodeType)
8989

9090
metadata = {
@@ -125,13 +125,15 @@ def test_exception_table(self):
125125
# code for "try: pass\n except: pass"
126126
insts = [
127127
('RESUME', 0),
128-
('SETUP_FINALLY', 3),
129-
('RETURN_CONST', 0),
130-
('SETUP_CLEANUP', 8),
128+
('SETUP_FINALLY', 4),
129+
('LOAD_CONST', 0),
130+
('RETURN_VALUE', None),
131+
('SETUP_CLEANUP', 10),
131132
('PUSH_EXC_INFO', None),
132133
('POP_TOP', None),
133134
('POP_EXCEPT', None),
134-
('RETURN_CONST', 0),
135+
('LOAD_CONST', 0),
136+
('RETURN_VALUE', None),
135137
('COPY', 3),
136138
('POP_EXCEPT', None),
137139
('RERAISE', 1),
@@ -144,4 +146,4 @@ def test_exception_table(self):
144146
L1 to L2 -> L2 [0]
145147
L2 to L3 -> L3 [1] lasti
146148
""")
147-
self.assertTrue(output.getvalue().endswith(exc_table))
149+
self.assertEndsWith(output.getvalue(), exc_table)

Lib/test/test_compiler_codegen.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,17 @@ def test_if_expression(self):
2626
false_lbl = self.Label()
2727
expected = [
2828
('RESUME', 0, 0),
29+
('ANNOTATIONS_PLACEHOLDER', None),
2930
('LOAD_CONST', 0, 1),
3031
('TO_BOOL', 0, 1),
3132
('POP_JUMP_IF_FALSE', false_lbl := self.Label(), 1),
32-
('LOAD_CONST', 1, 1),
33+
('LOAD_CONST', 1, 1), # 42
3334
('JUMP_NO_INTERRUPT', exit_lbl := self.Label()),
3435
false_lbl,
35-
('LOAD_CONST', 2, 1),
36+
('LOAD_CONST', 2, 1), # 24
3637
exit_lbl,
3738
('POP_TOP', None),
38-
('LOAD_CONST', 3),
39+
('LOAD_CONST', 1),
3940
('RETURN_VALUE', None),
4041
]
4142
self.codegen_test(snippet, expected)
@@ -45,6 +46,7 @@ def test_for_loop(self):
4546
false_lbl = self.Label()
4647
expected = [
4748
('RESUME', 0, 0),
49+
('ANNOTATIONS_PLACEHOLDER', None),
4850
('LOAD_NAME', 0, 1),
4951
('GET_ITER', None, 1),
5052
loop_lbl := self.Label(),
@@ -59,7 +61,7 @@ def test_for_loop(self):
5961
('JUMP', loop_lbl),
6062
exit_lbl,
6163
('END_FOR', None),
62-
('POP_TOP', None),
64+
('POP_ITER', None),
6365
('LOAD_CONST', 0),
6466
('RETURN_VALUE', None),
6567
]
@@ -73,6 +75,7 @@ def f(x):
7375
expected = [
7476
# Function definition
7577
('RESUME', 0),
78+
('ANNOTATIONS_PLACEHOLDER', None),
7679
('LOAD_CONST', 0),
7780
('MAKE_FUNCTION', None),
7881
('STORE_NAME', 0),
@@ -82,7 +85,7 @@ def f(x):
8285
# Function body
8386
('RESUME', 0),
8487
('LOAD_FAST', 0),
85-
('LOAD_CONST', 1),
88+
('LOAD_CONST', 42),
8689
('BINARY_OP', 0),
8790
('RETURN_VALUE', None),
8891
('LOAD_CONST', 0),
@@ -106,6 +109,7 @@ def g():
106109
expected = [
107110
# Function definition
108111
('RESUME', 0),
112+
('ANNOTATIONS_PLACEHOLDER', None),
109113
('LOAD_CONST', 0),
110114
('MAKE_FUNCTION', None),
111115
('STORE_NAME', 0),
@@ -125,9 +129,9 @@ def g():
125129
[
126130
('RESUME', 0),
127131
('NOP', None),
128-
('LOAD_CONST', 1),
132+
('LOAD_CONST', 12),
129133
('RETURN_VALUE', None),
130-
('LOAD_CONST', 0),
134+
('LOAD_CONST', 1),
131135
('RETURN_VALUE', None),
132136
],
133137
[
@@ -141,7 +145,7 @@ def g():
141145
('LOAD_CONST', 4),
142146
('STORE_FAST', 3),
143147
('NOP', None),
144-
('LOAD_CONST', 5),
148+
('LOAD_CONST', 42),
145149
('RETURN_VALUE', None),
146150
('LOAD_CONST', 0),
147151
('RETURN_VALUE', None),

0 commit comments

Comments
 (0)