diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2016-02-15 10:02:11 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2016-02-15 10:02:11 -0500 |
commit | d2f0e8e892417a453a9c1bd9b6237366520d7d51 (patch) | |
tree | a7d84101751308eb891f7bf6b8bcc1c313947279 /coverage/parser.py | |
parent | 1db658008c1c5b8802c7eeaa2bdfab55441949fe (diff) | |
download | python-coveragepy-git-d2f0e8e892417a453a9c1bd9b6237366520d7d51.tar.gz |
Clean up new helper
Diffstat (limited to 'coverage/parser.py')
-rw-r--r-- | coverage/parser.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/coverage/parser.py b/coverage/parser.py index 6427a0cb..84cd3d1d 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -814,22 +814,27 @@ class AstArcAnalyzer(object): 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, 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, 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, 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, exits) self.process_return_exits(return_exits) return exits - def combine_finally_starts(self, starts, exits): - cause = " or ".join(cause.format(lineno=lineno) for lineno, cause in sorted(starts) if cause is not None) + def _combine_finally_starts(self, starts, exits): + """Helper for building the cause of `finally` branches.""" + causes = [] + for lineno, cause in sorted(starts): + if cause is not None: + causes.append(cause.format(lineno=lineno)) + cause = " or ".join(causes) exits = set(ArcStart(ex.lineno, cause) for ex in exits) return exits |