bpo-42645: Make sure that return/break/continue are only traced once when exiting via a finally block. (GH-23780)
* Make sure that return/break/continue are only traced once when exiting via a finally block.
* Add test for return in try-finally.
* Update importlib
diff --git a/Lib/test/test_dis.py b/Lib/test/test_dis.py
index eb93170..f279f75 100644
--- a/Lib/test/test_dis.py
+++ b/Lib/test/test_dis.py
@@ -366,18 +366,14 @@ def _tryfinallyconst(b):
%3d 6 LOAD_FAST 1 (b)
8 CALL_FUNCTION 0
10 POP_TOP
-
-%3d 12 RETURN_VALUE
-
-%3d >> 14 LOAD_FAST 1 (b)
+ 12 RETURN_VALUE
+ >> 14 LOAD_FAST 1 (b)
16 CALL_FUNCTION 0
18 POP_TOP
20 RERAISE
""" % (_tryfinally.__code__.co_firstlineno + 1,
_tryfinally.__code__.co_firstlineno + 2,
_tryfinally.__code__.co_firstlineno + 4,
- _tryfinally.__code__.co_firstlineno + 2,
- _tryfinally.__code__.co_firstlineno + 4,
)
dis_tryfinallyconst = """\
@@ -388,19 +384,15 @@ def _tryfinallyconst(b):
%3d 4 LOAD_FAST 0 (b)
6 CALL_FUNCTION 0
8 POP_TOP
-
-%3d 10 LOAD_CONST 1 (1)
+ 10 LOAD_CONST 1 (1)
12 RETURN_VALUE
-
-%3d >> 14 LOAD_FAST 0 (b)
+ >> 14 LOAD_FAST 0 (b)
16 CALL_FUNCTION 0
18 POP_TOP
20 RERAISE
""" % (_tryfinallyconst.__code__.co_firstlineno + 1,
_tryfinallyconst.__code__.co_firstlineno + 2,
_tryfinallyconst.__code__.co_firstlineno + 4,
- _tryfinallyconst.__code__.co_firstlineno + 2,
- _tryfinallyconst.__code__.co_firstlineno + 4,
)
def _g(x):