File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed
Misc/NEWS.d/next/Core and Builtins Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -1166,6 +1166,44 @@ def test_multiline_assert_rewritten_as_method_call(self):
1166
1166
tree .body [0 ] = new_node
1167
1167
compile (tree , "<test>" , "exec" )
1168
1168
1169
+ def test_push_null_load_global_positions (self ):
1170
+ source_template = """
1171
+ import abc, dis
1172
+ import ast as art
1173
+
1174
+ abc = None
1175
+ dix = dis
1176
+ ast = art
1177
+
1178
+ def f():
1179
+ {}
1180
+ """
1181
+ for body in [
1182
+ " abc.a()" ,
1183
+ " art.a()" ,
1184
+ " ast.a()" ,
1185
+ " dis.a()" ,
1186
+ " dix.a()" ,
1187
+ " abc[...]()" ,
1188
+ " art()()" ,
1189
+ " (ast or ...)()" ,
1190
+ " [dis]()" ,
1191
+ " (dix + ...)()" ,
1192
+ ]:
1193
+ with self .subTest (body ):
1194
+ namespace = {}
1195
+ source = textwrap .dedent (source_template .format (body ))
1196
+ exec (source , namespace )
1197
+ code = namespace ["f" ].__code__
1198
+ self .assertOpcodeSourcePositionIs (
1199
+ code ,
1200
+ "LOAD_GLOBAL" ,
1201
+ line = 10 ,
1202
+ end_line = 10 ,
1203
+ column = 4 ,
1204
+ end_column = 7 ,
1205
+ )
1206
+
1169
1207
1170
1208
class TestExpressionStackSize (unittest .TestCase ):
1171
1209
# These tests check that the computed stack size for a code object
Original file line number Diff line number Diff line change
1
+ Fix incorrect source location info caused by certain optimizations in the
2
+ bytecode compiler.
Original file line number Diff line number Diff line change @@ -9045,7 +9045,10 @@ clean_basic_block(basicblock *bb) {
9045
9045
/* or, if the next instruction has same line number or no line number */
9046
9046
if (src < bb -> b_iused - 1 ) {
9047
9047
int next_lineno = bb -> b_instr [src + 1 ].i_lineno ;
9048
- if (next_lineno < 0 || next_lineno == lineno ) {
9048
+ if (next_lineno == lineno ) {
9049
+ continue ;
9050
+ }
9051
+ if (next_lineno < 0 ) {
9049
9052
COPY_INSTR_LOC (bb -> b_instr [src ], bb -> b_instr [src + 1 ]);
9050
9053
continue ;
9051
9054
}
You can’t perform that action at this time.
0 commit comments