From b8f054fcac467af98f23a8915df29a458437ad71 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Sun, 7 Feb 2016 08:03:52 -0500 Subject: Properly handle {**{'a':1}} literals --- coverage/parser.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'coverage/parser.py') diff --git a/coverage/parser.py b/coverage/parser.py index e1f09c23..b73ac685 100644 --- a/coverage/parser.py +++ b/coverage/parser.py @@ -420,7 +420,12 @@ class AstArcAnalyzer(object): def _line__Dict(self, node): # Python 3.5 changed how dict literals are made. if env.PYVERSION >= (3, 5) and node.keys: - return node.keys[0].lineno + if node.keys[0] is not None: + return node.keys[0].lineno + else: + # Unpacked dict literals `{**{'a':1}}` have None as the key, + # use the value in that case. + return node.values[0].lineno else: return node.lineno @@ -439,7 +444,7 @@ class AstArcAnalyzer(object): OK_TO_DEFAULT = set([ "Assign", "Assert", "AugAssign", "Delete", "Exec", "Expr", "Global", - "Import", "ImportFrom", "Pass", "Print", + "Import", "ImportFrom", "Nonlocal", "Pass", "Print", ]) def add_arcs(self, node): -- cgit v1.2.1