[Python-checkins] cpython (merge 3.2 -> default): merge 3.2 (#14612)
benjamin.peterson
python-checkins at python.org
Wed Apr 18 17:24:41 CEST 2012
http://hg.python.org/cpython/rev/0695f5d028a7
changeset: 76394:0695f5d028a7
parent: 76392:4111a2b5ff57
parent: 76393:6a0a073e8461
user: Benjamin Peterson <benjamin at python.org>
date: Wed Apr 18 11:19:00 2012 -0400
summary:
merge 3.2 (#14612)
files:
Lib/test/test_sys_settrace.py | 11 +++++++++++
Misc/NEWS | 2 ++
Objects/frameobject.c | 6 ++++--
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py
--- a/Lib/test/test_sys_settrace.py
+++ b/Lib/test/test_sys_settrace.py
@@ -675,6 +675,14 @@
no_jump_to_non_integers.jump = (2, "Spam")
no_jump_to_non_integers.output = [True]
+def jump_across_with(output):
+ with open(support.TESTFN, "wb") as fp:
+ pass
+ with open(support.TESTFN, "wb") as fp:
+ pass
+jump_across_with.jump = (1, 3)
+jump_across_with.output = []
+
# This verifies that you can't set f_lineno via _getframe or similar
# trickery.
def no_jump_without_trace_function():
@@ -750,6 +758,9 @@
# Must set sys.settrace(None) in setUp(), else condition is not
# triggered.
no_jump_without_trace_function()
+ def test_jump_across_with(self):
+ self.addCleanup(support.unlink, support.TESTFN)
+ self.run_test(jump_across_with)
def test_20_large_function(self):
d = {}
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -14,6 +14,8 @@
object for importlib.util.module_for_loader and
importlib.machinery.PathFinder.
+- Issue #14612: Fix jumping around with blocks by setting f_lineno.
+
- Issue #14592: Attempting a relative import w/o __package__ or __name__ set in
globals raises a KeyError.
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -199,6 +199,7 @@
case SETUP_LOOP:
case SETUP_EXCEPT:
case SETUP_FINALLY:
+ case SETUP_WITH:
blockstack[blockstack_top++] = addr;
in_finally[blockstack_top-1] = 0;
break;
@@ -206,7 +207,7 @@
case POP_BLOCK:
assert(blockstack_top > 0);
setup_op = code[blockstack[blockstack_top-1]];
- if (setup_op == SETUP_FINALLY) {
+ if (setup_op == SETUP_FINALLY || setup_op == SETUP_WITH) {
in_finally[blockstack_top-1] = 1;
}
else {
@@ -221,7 +222,7 @@
* be seeing such an END_FINALLY.) */
if (blockstack_top > 0) {
setup_op = code[blockstack[blockstack_top-1]];
- if (setup_op == SETUP_FINALLY) {
+ if (setup_op == SETUP_FINALLY || setup_op == SETUP_WITH) {
blockstack_top--;
}
}
@@ -283,6 +284,7 @@
case SETUP_LOOP:
case SETUP_EXCEPT:
case SETUP_FINALLY:
+ case SETUP_WITH:
delta_iblock++;
break;
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list