summaryrefslogtreecommitdiff
path: root/coverage/parser.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2018-02-09 16:26:39 -0500
committerNed Batchelder <ned@nedbatchelder.com>2018-02-09 16:26:39 -0500
commit700f7083743424ba4370fe6892006a090db08909 (patch)
treee13eb8a28346586901d32e01f72d0044eacb6596 /coverage/parser.py
parent49bd2804c472c7bc3482dffcc47f0189ae72faaf (diff)
downloadpython-coveragepy-git-700f7083743424ba4370fe6892006a090db08909.tar.gz
Properly handle empty decorated functions in 3.7. #640
Diffstat (limited to 'coverage/parser.py')
-rw-r--r--coverage/parser.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/coverage/parser.py b/coverage/parser.py
index 590eacee..6e6cccd5 100644
--- a/coverage/parser.py
+++ b/coverage/parser.py
@@ -831,12 +831,13 @@ class AstArcAnalyzer(object):
# in `self.statements`. For some constructs, `line_for_node` is
# not what we'd think of as the first line in the statement, so map
# it to the first one.
- body_start = self.line_for_node(node.body[0])
- body_start = self.multiline.get(body_start, body_start)
- for lineno in range(last+1, body_start):
- if lineno in self.statements:
- self.add_arc(last, lineno)
- last = lineno
+ if node.body:
+ body_start = self.line_for_node(node.body[0])
+ body_start = self.multiline.get(body_start, body_start)
+ for lineno in range(last+1, body_start):
+ if lineno in self.statements:
+ self.add_arc(last, lineno)
+ last = lineno
# The body is handled in collect_arcs.
return set([ArcStart(last)])