more rearrange

This commit is contained in:
Anthony Scopatz 2015-01-25 14:57:25 -06:00
parent 19903c10c9
commit 166acafc67
2 changed files with 5 additions and 9 deletions

View file

@ -303,7 +303,7 @@ def test_set_one():
yield check_ast, '{42}'
#DEBUG_LEVEL = 1
DEBUG_LEVEL = 1
#DEBUG_LEVEL = 100

View file

@ -31,7 +31,9 @@ def has_elts(x):
def ensure_has_elts(x, lineno=1, col_offset=1):
"""Ensures that x is an AST node with elements."""
if not has_elts(x):
x = ast.Tuple(elts=[x], ctx=ast.Load(), lineno=lineno,
if not isinstance(x, Iterable):
x = [x]
x = ast.Tuple(elts=x, ctx=ast.Load(), lineno=lineno,
col_offset=col_offset)
return x
@ -1033,13 +1035,7 @@ class Parser(object):
| test_or_star_expr comma_test_or_star_expr_list_opt comma_opt
"""
p1, p2 = p[1], p[2]
if hasattr(p1, 'elts'):
p0 = p1
else:
if not isinstance(p1, Iterable):
p1 = [p1]
p0 = ast.Tuple(elts=p1, ctx=ast.Load(), lineno=self.lineno,
col_offset=self.col)
p0 = ensure_has_elts(p1, lineno=self.lineno, col_offset=self.col)
if len(p) == 3:
if p2 is None:
pass