| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1087,7 +1087,7 @@ def jumpy(): | |||
| 1087 | 1087 | Instruction(opname='CALL_FUNCTION', opcode=131, arg=1, argval=1, argrepr='', offset=154, starts_line=None, is_jump_target=False), | |
| 1088 | 1088 | Instruction(opname='POP_TOP', opcode=1, arg=None, argval=None, argrepr='', offset=156, starts_line=None, is_jump_target=False), | |
| 1089 | 1089 | Instruction(opname='POP_BLOCK', opcode=87, arg=None, argval=None, argrepr='', offset=158, starts_line=None, is_jump_target=False), | |
| 1090 | - Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=160, starts_line=None, is_jump_target=False), | ||
| 1090 | + Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=None, argrepr='None', offset=160, starts_line=25, is_jump_target=False), | ||
| 1091 | 1091 | Instruction(opname='DUP_TOP', opcode=4, arg=None, argval=None, argrepr='', offset=162, starts_line=None, is_jump_target=False), | |
| 1092 | 1092 | Instruction(opname='DUP_TOP', opcode=4, arg=None, argval=None, argrepr='', offset=164, starts_line=None, is_jump_target=False), | |
| 1093 | 1093 | Instruction(opname='CALL_FUNCTION', opcode=131, arg=3, argval=3, argrepr='', offset=166, starts_line=None, is_jump_target=False), | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -936,10 +936,11 @@ def func(): | |||
| 936 | 936 | (-4, 'line'), | |
| 937 | 937 | (-4, 'return'), | |
| 938 | 938 | (2, 'line'), | |
| 939 | + (1, 'line'), | ||
| 939 | 940 | (-3, 'call'), | |
| 940 | 941 | (-2, 'line'), | |
| 941 | 942 | (-2, 'return'), | |
| 942 | - (2, 'return')]) | ||
| 943 | + (1, 'return')]) | ||
| 943 | 944 | ||
| 944 | 945 | def test_if_false_in_try_except(self): | |
| 945 | 946 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,2 @@ | |||
| 1 | + Set frame.f_lineno to the line number of the 'with' kweyword when executing | ||
| 2 | + the call to ``__exit__``. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1745,6 +1745,7 @@ static int | |||
| 1745 | 1745 | compiler_unwind_fblock(struct compiler *c, struct fblockinfo *info, | |
| 1746 | 1746 | int preserve_tos) | |
| 1747 | 1747 | { | |
| 1748 | + int loc; | ||
| 1748 | 1749 | switch (info->fb_type) { | |
| 1749 | 1750 | case WHILE_LOOP: | |
| 1750 | 1751 | case EXCEPTION_HANDLER: | |
@@ -1797,6 +1798,8 @@ compiler_unwind_fblock(struct compiler *c, struct fblockinfo *info, | |||
| 1797 | 1798 | ||
| 1798 | 1799 | case WITH: | |
| 1799 | 1800 | case ASYNC_WITH: | |
| 1801 | + loc = c->u->u_lineno; | ||
| 1802 | + SET_LOC(c, (stmt_ty)info->fb_datum); | ||
| 1800 | 1803 | ADDOP(c, POP_BLOCK); | |
| 1801 | 1804 | if (preserve_tos) { | |
| 1802 | 1805 | ADDOP(c, ROT_TWO); | |
@@ -1810,6 +1813,7 @@ compiler_unwind_fblock(struct compiler *c, struct fblockinfo *info, | |||
| 1810 | 1813 | ADDOP(c, YIELD_FROM); | |
| 1811 | 1814 | } | |
| 1812 | 1815 | ADDOP(c, POP_TOP); | |
| 1816 | + c->u->u_lineno = loc; | ||
| 1813 | 1817 | return 1; | |
| 1814 | 1818 | ||
| 1815 | 1819 | case HANDLER_CLEANUP: | |
@@ -4990,7 +4994,7 @@ compiler_async_with(struct compiler *c, stmt_ty s, int pos) | |||
| 4990 | 4994 | ||
| 4991 | 4995 | /* SETUP_ASYNC_WITH pushes a finally block. */ | |
| 4992 | 4996 | compiler_use_next_block(c, block); | |
| 4993 | - if (!compiler_push_fblock(c, ASYNC_WITH, block, final, NULL)) { | ||
| 4997 | + if (!compiler_push_fblock(c, ASYNC_WITH, block, final, s)) { | ||
| 4994 | 4998 | return 0; | |
| 4995 | 4999 | } | |
| 4996 | 5000 | ||
@@ -5016,6 +5020,7 @@ compiler_async_with(struct compiler *c, stmt_ty s, int pos) | |||
| 5016 | 5020 | /* For successful outcome: | |
| 5017 | 5021 | * call __exit__(None, None, None) | |
| 5018 | 5022 | */ | |
| 5023 | + SET_LOC(c, s); | ||
| 5019 | 5024 | if(!compiler_call_exit_with_nones(c)) | |
| 5020 | 5025 | return 0; | |
| 5021 | 5026 | ADDOP(c, GET_AWAITABLE); | |
@@ -5028,7 +5033,6 @@ compiler_async_with(struct compiler *c, stmt_ty s, int pos) | |||
| 5028 | 5033 | ||
| 5029 | 5034 | /* For exceptional outcome: */ | |
| 5030 | 5035 | compiler_use_next_block(c, final); | |
| 5031 | - | ||
| 5032 | 5036 | ADDOP(c, WITH_EXCEPT_START); | |
| 5033 | 5037 | ADDOP(c, GET_AWAITABLE); | |
| 5034 | 5038 | ADDOP_LOAD_CONST(c, Py_None); | |
@@ -5082,7 +5086,7 @@ compiler_with(struct compiler *c, stmt_ty s, int pos) | |||
| 5082 | 5086 | ||
| 5083 | 5087 | /* SETUP_WITH pushes a finally block. */ | |
| 5084 | 5088 | compiler_use_next_block(c, block); | |
| 5085 | - if (!compiler_push_fblock(c, WITH, block, final, NULL)) { | ||
| 5089 | + if (!compiler_push_fblock(c, WITH, block, final, s)) { | ||
| 5086 | 5090 | return 0; | |
| 5087 | 5091 | } | |
| 5088 | 5092 | ||
@@ -5112,14 +5116,14 @@ compiler_with(struct compiler *c, stmt_ty s, int pos) | |||
| 5112 | 5116 | /* For successful outcome: | |
| 5113 | 5117 | * call __exit__(None, None, None) | |
| 5114 | 5118 | */ | |
| 5119 | + SET_LOC(c, s); | ||
| 5115 | 5120 | if (!compiler_call_exit_with_nones(c)) | |
| 5116 | 5121 | return 0; | |
| 5117 | 5122 | ADDOP(c, POP_TOP); | |
| 5118 | 5123 | ADDOP_JUMP(c, JUMP_FORWARD, exit); | |
| 5119 | 5124 | ||
| 5120 | 5125 | /* For exceptional outcome: */ | |
| 5121 | 5126 | compiler_use_next_block(c, final); | |
| 5122 | - | ||
| 5123 | 5127 | ADDOP(c, WITH_EXCEPT_START); | |
| 5124 | 5128 | compiler_with_except_finish(c); | |
| 5125 | 5129 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments