diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2016-02-07 08:03:52 -0500 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2016-02-07 08:03:52 -0500 |
commit | fa1992f85f27d61389ea0e99303278526b8cba63 (patch) | |
tree | 8342c00b7dce2517c37a4ebe933bbe57502e893a /coverage/parser.py | |
parent | f7b59a7264003e8003c1a051bf57ab5951cabc22 (diff) | |
download | python-coveragepy-fa1992f85f27d61389ea0e99303278526b8cba63.tar.gz |
Properly handle {**{'a':1}} literals
Diffstat (limited to 'coverage/parser.py')
-rw-r--r-- | coverage/parser.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/coverage/parser.py b/coverage/parser.py index e1f09c2..b73ac68 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): |