mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 16:34:47 +01:00
revert some changes
This commit is contained in:
parent
989238eeaa
commit
0d3519f954
5 changed files with 6 additions and 45 deletions
|
@ -60,9 +60,6 @@ else:
|
|||
def test_ls_dashl():
|
||||
yield check_eval, 'ls -l'
|
||||
|
||||
def test_ls_dashl_2():
|
||||
yield check_eval, '$[ls -l]'
|
||||
|
||||
def test_which_ls():
|
||||
yield check_eval, 'which ls'
|
||||
|
||||
|
|
|
@ -58,7 +58,6 @@ def mock_xonsh_env(xenv):
|
|||
builtins.__xonsh_regexpath__ = lambda x: []
|
||||
builtins.__xonsh_subproc_captured__ = sp
|
||||
builtins.__xonsh_subproc_uncaptured__ = sp
|
||||
builtins.__xonsh_subproc_noreturn__ = sp
|
||||
builtins.__xonsh_ensure_list_of_strs__ = ensure_list_of_strs
|
||||
builtins.evalx = eval
|
||||
builtins.execx = None
|
||||
|
@ -75,7 +74,6 @@ def mock_xonsh_env(xenv):
|
|||
del builtins.__xonsh_regexpath__
|
||||
del builtins.__xonsh_subproc_captured__
|
||||
del builtins.__xonsh_subproc_uncaptured__
|
||||
del builtins.__xonsh_subproc_noreturn__
|
||||
del builtins.__xonsh_ensure_list_of_strs__
|
||||
del builtins.evalx
|
||||
del builtins.execx
|
||||
|
|
21
xonsh/ast.py
21
xonsh/ast.py
|
@ -91,7 +91,6 @@ class CtxAwareTransformer(NodeTransformer):
|
|||
self.contexts = []
|
||||
self.lines = None
|
||||
self.mode = None
|
||||
self.forced_subproc = False
|
||||
|
||||
def ctxvisit(self, node, inp, ctx, mode='exec'):
|
||||
"""Transforms the node in a context-dependent way.
|
||||
|
@ -138,10 +137,9 @@ class CtxAwareTransformer(NodeTransformer):
|
|||
if self.mode == 'eval':
|
||||
mincol = len(line) - len(line.lstrip())
|
||||
maxcol = None
|
||||
else:
|
||||
else:
|
||||
mincol = min_col(node)
|
||||
maxcol = max_col(node) + 1
|
||||
self.forced_subproc = True
|
||||
spline = subproc_toks(line,
|
||||
mincol=mincol,
|
||||
maxcol=maxcol,
|
||||
|
@ -177,16 +175,11 @@ class CtxAwareTransformer(NodeTransformer):
|
|||
inscope = self.is_in_scope(body)
|
||||
if not inscope:
|
||||
node.body = self.try_subproc_toks(body)
|
||||
if isinstance(node.body, list):
|
||||
node.body[0] = self.visit(node.body[0])
|
||||
else:
|
||||
node.body = self.visit(node.body)
|
||||
return node
|
||||
|
||||
def visit_Expr(self, node):
|
||||
"""Handle visiting an expression."""
|
||||
if self.is_in_scope(node):
|
||||
node.value = self.visit(node.value)
|
||||
return node
|
||||
else:
|
||||
newnode = self.try_subproc_toks(node)
|
||||
|
@ -197,17 +190,8 @@ class CtxAwareTransformer(NodeTransformer):
|
|||
if hasattr(node, 'max_lineno'):
|
||||
newnode.max_lineno = node.max_lineno
|
||||
newnode.max_col = node.max_col
|
||||
newnode.value = self.visit(newnode.value)
|
||||
return newnode
|
||||
|
||||
def visit_Call(self, node):
|
||||
if (isinstance(node.func, Name) and
|
||||
node.func.id == '__xonsh_subproc_uncaptured__' and
|
||||
self.forced_subproc):
|
||||
node.func.id = '__xonsh_subproc_noreturn__'
|
||||
self.forced_subproc = False
|
||||
return node
|
||||
|
||||
def visit_Assign(self, node):
|
||||
"""Handle visiting an assignment statement."""
|
||||
ups = set()
|
||||
|
@ -216,7 +200,6 @@ class CtxAwareTransformer(NodeTransformer):
|
|||
ups.update(leftmostname(elt) for elt in targ.elts)
|
||||
elif isinstance(targ, BinOp):
|
||||
newnode = self.try_subproc_toks(node)
|
||||
newnode = self.visit(newnode)
|
||||
if newnode is node:
|
||||
ups.add(leftmostname(targ))
|
||||
else:
|
||||
|
@ -325,6 +308,6 @@ def pdump(s, **kwargs):
|
|||
if '(' in post or '[' in post or '{' in post:
|
||||
post = pdump(post)
|
||||
return pre + mid + post
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -635,12 +635,10 @@ def run_subproc(cmds, captured=True):
|
|||
output = output.replace('\r\n', '\n')
|
||||
else:
|
||||
hist.last_cmd_out = output
|
||||
if not prev_is_proxy and prev_proc.returncode > 0 and ENV.get('RAISE_SUBPROC_ERROR'):
|
||||
if not prev_is_proxy and hist.last_cmd_rtn > 0 and ENV.get('RAISE_SUBPROC_ERROR'):
|
||||
raise CalledProcessError(hist.last_cmd_rtn, aliased_cmd, output=output)
|
||||
if captured:
|
||||
return output
|
||||
else:
|
||||
return prev_proc.returncode
|
||||
|
||||
|
||||
def subproc_captured(*cmds):
|
||||
|
@ -651,22 +649,12 @@ def subproc_captured(*cmds):
|
|||
|
||||
|
||||
def subproc_uncaptured(*cmds):
|
||||
"""
|
||||
Runs a subprocess, without capturing the output. Returns the return code
|
||||
of the command that was run.
|
||||
"""Runs a subprocess, without capturing the output. Returns the stdout
|
||||
that was produced as a str.
|
||||
"""
|
||||
return run_subproc(cmds, captured=False)
|
||||
|
||||
|
||||
def subproc_noreturn(*cmds):
|
||||
"""
|
||||
Runs a subprocess, without capturing the output. Always returns
|
||||
``None``.
|
||||
"""
|
||||
run_subproc(cmds, captured=False)
|
||||
return None
|
||||
|
||||
|
||||
def ensure_list_of_strs(x):
|
||||
"""Ensures that x is a list of strings."""
|
||||
if isinstance(x, string_types):
|
||||
|
@ -702,7 +690,6 @@ def load_builtins(execer=None, config=None):
|
|||
del builtins.quit
|
||||
builtins.__xonsh_subproc_captured__ = subproc_captured
|
||||
builtins.__xonsh_subproc_uncaptured__ = subproc_uncaptured
|
||||
builtins.__xonsh_subproc_noreturn__ = subproc_noreturn
|
||||
builtins.__xonsh_execer__ = execer
|
||||
builtins.__xonsh_all_jobs__ = {}
|
||||
builtins.__xonsh_active_job__ = None
|
||||
|
@ -752,7 +739,6 @@ def unload_builtins():
|
|||
'__xonsh_pyquit__',
|
||||
'__xonsh_subproc_captured__',
|
||||
'__xonsh_subproc_uncaptured__',
|
||||
'__xonsh_subproc_noreturn__',
|
||||
'__xonsh_execer__',
|
||||
'evalx',
|
||||
'execx',
|
||||
|
|
|
@ -123,9 +123,7 @@ class Execer(object):
|
|||
stacklevel=stacklevel)
|
||||
if code is None:
|
||||
return None # handles comment only input
|
||||
e = exec(code, glbs, locs)
|
||||
self.ctxtransformer.forced_subproc = False
|
||||
return e
|
||||
return exec(code, glbs, locs)
|
||||
|
||||
def _find_next_break(self, line, mincol):
|
||||
if mincol >= 1:
|
||||
|
@ -192,7 +190,6 @@ class Execer(object):
|
|||
# and it still doesn't work, adding more won't help
|
||||
# anything
|
||||
raise original_error
|
||||
self.ctxtransformer.forced_subproc = True
|
||||
sbpline = subproc_toks(line,
|
||||
returnline=True,
|
||||
maxcol=maxcol,
|
||||
|
|
Loading…
Add table
Reference in a new issue