File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -671,6 +671,14 @@ def no_jump_to_non_integers(output):
671671no_jump_to_non_integers .jump = (2 , "Spam" )
672672no_jump_to_non_integers .output = [True ]
673673
674+ def jump_across_with (output ):
675+ with open (support .TESTFN , "wb" ) as fp :
676+ pass
677+ with open (support .TESTFN , "wb" ) as fp :
678+ pass
679+ jump_across_with .jump = (1 , 3 )
680+ jump_across_with .output = []
681+
674682# This verifies that you can't set f_lineno via _getframe or similar
675683# trickery.
676684def no_jump_without_trace_function ():
@@ -740,6 +748,9 @@ def test_18_no_jump_to_non_integers(self):
740748 self .run_test (no_jump_to_non_integers )
741749 def test_19_no_jump_without_trace_function (self ):
742750 no_jump_without_trace_function ()
751+ def test_jump_across_with (self ):
752+ self .addCleanup (support .unlink , support .TESTFN )
753+ self .run_test (jump_across_with )
743754
744755 def test_20_large_function (self ):
745756 d = {}
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ What's New in Python 3.2.4
1010Core and Builtins
1111-----------------
1212
13+ - Issue #14612: Fix jumping around with blocks by setting f_lineno.
14+
1315- Issue #14607: Fix defaults keyword-only arguments which started with ``__``.
1416
1517- Issue #13889: Check and (if necessary) set FPU control word before calling
Original file line number Diff line number Diff line change @@ -199,14 +199,15 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
199199 case SETUP_LOOP :
200200 case SETUP_EXCEPT :
201201 case SETUP_FINALLY :
202+ case SETUP_WITH :
202203 blockstack [blockstack_top ++ ] = addr ;
203204 in_finally [blockstack_top - 1 ] = 0 ;
204205 break ;
205206
206207 case POP_BLOCK :
207208 assert (blockstack_top > 0 );
208209 setup_op = code [blockstack [blockstack_top - 1 ]];
209- if (setup_op == SETUP_FINALLY ) {
210+ if (setup_op == SETUP_FINALLY || setup_op == SETUP_WITH ) {
210211 in_finally [blockstack_top - 1 ] = 1 ;
211212 }
212213 else {
@@ -221,7 +222,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
221222 * be seeing such an END_FINALLY.) */
222223 if (blockstack_top > 0 ) {
223224 setup_op = code [blockstack [blockstack_top - 1 ]];
224- if (setup_op == SETUP_FINALLY ) {
225+ if (setup_op == SETUP_FINALLY || setup_op == SETUP_WITH ) {
225226 blockstack_top -- ;
226227 }
227228 }
@@ -283,6 +284,7 @@ frame_setlineno(PyFrameObject *f, PyObject* p_new_lineno)
283284 case SETUP_LOOP :
284285 case SETUP_EXCEPT :
285286 case SETUP_FINALLY :
287+ case SETUP_WITH :
286288 delta_iblock ++ ;
287289 break ;
288290
You can’t perform that action at this time.
0 commit comments