| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1031,6 +1031,20 @@ async def test(aseq): | |||
| 1031 | 1031 | code_lines = self.get_code_lines(test.__code__) | |
| 1032 | 1032 | self.assertEqual(expected_lines, code_lines) | |
| 1033 | 1033 | ||
| 1034 | + def test_lineno_of_backward_jump(self): | ||
| 1035 | + # Issue gh-107901 | ||
| 1036 | + def f(): | ||
| 1037 | + for i in x: | ||
| 1038 | + if y: | ||
| 1039 | + pass | ||
| 1040 | + | ||
| 1041 | + linenos = list(inst.positions.lineno | ||
| 1042 | + for inst in dis.get_instructions(f.__code__) | ||
| 1043 | + if inst.opname == 'JUMP_BACKWARD') | ||
| 1044 | + | ||
| 1045 | + self.assertTrue(len(linenos) > 0) | ||
| 1046 | + self.assertTrue(all(l is not None for l in linenos)) | ||
| 1047 | + | ||
| 1034 | 1048 | def test_big_dict_literal(self): | |
| 1035 | 1049 | # The compiler has a flushing point in "compiler_dict" that calls compiles | |
| 1036 | 1050 | # a portion of the dictionary literal when the loop that iterates over the items | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1 @@ | |||
| 1 | + Fix missing line number on :opcode:`JUMP_BACKWARD` at the end of a for loop. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -531,7 +531,7 @@ normalize_jumps_in_block(cfg_builder *g, basicblock *b) { | |||
| 531 | 531 | if (backwards_jump == NULL) { | |
| 532 | 532 | return ERROR; | |
| 533 | 533 | } | |
| 534 | - basicblock_addop(backwards_jump, JUMP, target->b_label.id, NO_LOCATION); | ||
| 534 | + basicblock_addop(backwards_jump, JUMP, target->b_label.id, last->i_loc); | ||
| 535 | 535 | backwards_jump->b_instr[0].i_target = target; | |
| 536 | 536 | last->i_opcode = reversed_opcode; | |
| 537 | 537 | last->i_target = b->b_next; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments