summaryrefslogtreecommitdiff
path: root/coverage/parser.py
diff options
context:
space:
mode:
authorloic@dachary.org <loic@dachary.org>2016-12-18 01:56:31 +0100
committerloic@dachary.org <loic@dachary.org>2016-12-18 01:56:31 +0100
commitb8eaf57399f82872cb7b371bc5b8ff2e9679a9ba (patch)
treebcbf4f13e43abf67a8164f87daaf54f8bf37130c /coverage/parser.py
parent878363970556406d1eed322f6bd8747af1145462 (diff)
downloadpython-coveragepy-git-b8eaf57399f82872cb7b371bc5b8ff2e9679a9ba.tar.gz
finally happens before return in a try #493
In a try block such as: if expr: try: return finally print pass the print happens before the return and cannot be followed by pass. The general case is that when the body/else/handlers in a try block all have return, break etc., the code behind finally: has no arc to the statement following the try block. close #493 --HG-- branch : issue-493-2
Diffstat (limited to 'coverage/parser.py')
-rw-r--r--coverage/parser.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/coverage/parser.py b/coverage/parser.py
index 71334b63..3d46bfa1 100644
--- a/coverage/parser.py
+++ b/coverage/parser.py
@@ -842,19 +842,21 @@ class AstArcAnalyzer(object):
try_block.return_from # or a `return`.
)
- exits = self.add_body_arcs(node.finalbody, prev_starts=final_from)
+ final_exits = self.add_body_arcs(node.finalbody, prev_starts=final_from)
if try_block.break_from:
- break_exits = self._combine_finally_starts(try_block.break_from, exits)
+ break_exits = self._combine_finally_starts(try_block.break_from, final_exits)
self.process_break_exits(break_exits)
if try_block.continue_from:
- continue_exits = self._combine_finally_starts(try_block.continue_from, exits)
+ continue_exits = self._combine_finally_starts(try_block.continue_from, final_exits)
self.process_continue_exits(continue_exits)
if try_block.raise_from:
- raise_exits = self._combine_finally_starts(try_block.raise_from, exits)
+ raise_exits = self._combine_finally_starts(try_block.raise_from, final_exits)
self.process_raise_exits(raise_exits)
if try_block.return_from:
- return_exits = self._combine_finally_starts(try_block.return_from, exits)
+ return_exits = self._combine_finally_starts(try_block.return_from, final_exits)
self.process_return_exits(return_exits)
+ if exits:
+ exits = final_exits
return exits