diff options
author | Claudiu Popa <pcmanticore@gmail.com> | 2016-01-04 14:46:43 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2016-01-04 14:46:43 +0200 |
commit | d39369f422ca344782aa2356a91e25f9db4e8192 (patch) | |
tree | ebbd2650ea8d6e47c7d04a748369fc7ea48d3c2b /astroid/tree/rebuilder.py | |
parent | 0a55e866e32548ea2de39db529802c22f2041b7f (diff) | |
download | astroid-git-d39369f422ca344782aa2356a91e25f9db4e8192.tar.gz |
Use keys and values as separate arguments for nodes.Dict
Dict was a bit different that the corresponding class from the
builtin ast module with respect to how it was initialized.
Instead of accepting a list of pairs, the initializer accepts
two arguments, one for keys, the other for values. For backward
compatibility, the class gained a new .items property.
Diffstat (limited to 'astroid/tree/rebuilder.py')
-rw-r--r-- | astroid/tree/rebuilder.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/astroid/tree/rebuilder.py b/astroid/tree/rebuilder.py index 81ef48d4..1d994876 100644 --- a/astroid/tree/rebuilder.py +++ b/astroid/tree/rebuilder.py @@ -370,7 +370,11 @@ class TreeRebuilder(object): """visit a Dict node by returning a fresh instance of it""" newnode = nodes.Dict(node.lineno, node.col_offset, parent) items = list(self._visit_dict_items(node, parent, newnode)) - newnode.postinit(items) + if items: + keys, values = zip(*items) + else: + keys, values = [], [] + newnode.postinit(keys, values) return newnode def visit_dictcomp(self, node, parent): |