Clean up with
This commit is contained in:
parent
b99460b632
commit
2ef9bc75d4
@ -1452,25 +1452,22 @@ class HyASTCompiler(object):
|
|||||||
raise HyTypeError(expr,
|
raise HyTypeError(expr,
|
||||||
"with expects a list, received `{0}'".format(
|
"with expects a list, received `{0}'".format(
|
||||||
type(args).__name__))
|
type(args).__name__))
|
||||||
if len(args) < 1:
|
if len(args) not in (1, 2):
|
||||||
raise HyTypeError(expr, "with needs [[arg (expr)]] or [[(expr)]]]")
|
raise HyTypeError(expr, "with needs [arg (expr)] or [(expr)]")
|
||||||
|
|
||||||
args.reverse()
|
|
||||||
ctx = self.compile(args.pop(0))
|
|
||||||
|
|
||||||
thing = None
|
thing = None
|
||||||
if args != []:
|
if len(args) == 2:
|
||||||
thing = self._storeize(args[0], self.compile(args.pop(0)))
|
thing = self._storeize(args[0], self.compile(args.pop(0)))
|
||||||
|
ctx = self.compile(args.pop(0))
|
||||||
|
|
||||||
body = self._compile_branch(expr)
|
body = self._compile_branch(expr)
|
||||||
|
|
||||||
|
# Store the result of the body in a tempvar
|
||||||
var = self.get_anon_var()
|
var = self.get_anon_var()
|
||||||
name = ast.Name(id=ast_str(var), arg=ast_str(var),
|
name = ast.Name(id=ast_str(var), arg=ast_str(var),
|
||||||
ctx=ast.Store(),
|
ctx=ast.Store(),
|
||||||
lineno=expr.start_line,
|
lineno=expr.start_line,
|
||||||
col_offset=expr.start_column)
|
col_offset=expr.start_column)
|
||||||
|
|
||||||
# Store the result of the body in a tempvar
|
|
||||||
body += ast.Assign(targets=[name],
|
body += ast.Assign(targets=[name],
|
||||||
value=body.force_expr,
|
value=body.force_expr,
|
||||||
lineno=expr.start_line,
|
lineno=expr.start_line,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user