bug fix for indented ctx sensitive parsing

This commit is contained in:
Anthony Scopatz 2015-03-15 01:29:25 -05:00
parent 9cf2c9b26c
commit c1ba1c502c
2 changed files with 10 additions and 4 deletions

View file

@ -42,6 +42,13 @@ def test_subproc_toks_git_nl():
assert_equal(exp, obs)
def test_subproc_toks_indent_ls():
s = 'ls -l'
exp = INDENT + '$[{0}]'.format(s)
obs = subproc_toks(INDENT + s, mincol=len(INDENT), lexer=LEXER,
returnline=True)
assert_equal(exp, obs)
def test_subproc_toks_indent_ls_nl():
s = 'ls -l'
exp = INDENT + '$[{0}]\n'.format(s)
obs = subproc_toks(INDENT + s + '\n', mincol=len(INDENT), lexer=LEXER,

View file

@ -99,11 +99,10 @@ class CtxAwareTransformer(NodeTransformer):
def try_subproc_toks(self, node):
"""Tries to parse the line of the node as a subprocess."""
line = self.lines[node.lineno - 1]
mincol = len(line) - len(line.lstrip())
maxcol = None if self.mode == 'eval' else node.col_offset
spline = subproc_toks(line,
maxcol=maxcol,
returnline=False,
lexer=self.parser.lexer).lstrip()
spline = subproc_toks(line, mincol=mincol, maxcol=maxcol,
returnline=False, lexer=self.parser.lexer)
try:
newnode = self.parser.parse(spline, mode=self.mode)
newnode = newnode.body