diff options
| author | Claudiu Popa <pcmanticore@gmail.com> | 2019-12-15 11:07:15 +0200 |
|---|---|---|
| committer | Claudiu Popa <pcmanticore@gmail.com> | 2019-12-15 11:07:15 +0200 |
| commit | d68f2935378ecce766c2ec9086c18e44d4b78572 (patch) | |
| tree | 84e9977293b71b78b819b619d8bbb7321c27ed08 /astroid | |
| parent | 18ca60d21066d6cc5de1aa600bfeacb4ab352cc3 (diff) | |
| download | astroid-git-d68f2935378ecce766c2ec9086c18e44d4b78572.tar.gz | |
``nodes.Const.itered`` returns a list of ``Const`` nodes, not strings
Because ``Const.itered`` was not returning proper nodes, pylint was failing
when trying to infer objects created from those nodes.
Close PyCQA/pylint#3306
Diffstat (limited to 'astroid')
| -rw-r--r-- | astroid/node_classes.py | 6 | ||||
| -rw-r--r-- | astroid/protocols.py | 4 |
2 files changed, 6 insertions, 4 deletions
diff --git a/astroid/node_classes.py b/astroid/node_classes.py index ebbcef09..b1344723 100644 --- a/astroid/node_classes.py +++ b/astroid/node_classes.py @@ -2576,13 +2576,13 @@ class Const(mixins.NoChildrenMixin, NodeNG, bases.Instance): """An iterator over the elements this node contains. :returns: The contents of this node. - :rtype: iterable(str) + :rtype: iterable(Const) :raises TypeError: If this node does not represent something that is iterable. """ if isinstance(self.value, str): - return self.value - raise TypeError() + return [const_factory(elem) for elem in self.value] + raise TypeError("Cannot iterate over type {!r}".format(type(self.value))) def pytype(self): """Get the name of the type that this node represents. diff --git a/astroid/protocols.py b/astroid/protocols.py index 09301511..33d90ea3 100644 --- a/astroid/protocols.py +++ b/astroid/protocols.py @@ -677,7 +677,9 @@ def starred_assigned_stmts(self, node=None, context=None, assign_path=None): break elts.pop() continue - # We're done + + # We're done unpacking. + elts = list(elts) packed = nodes.List( ctx=Store, parent=self, lineno=lhs.lineno, col_offset=lhs.col_offset ) |
