unbreak py3.3? need to re-add with

This commit is contained in:
Paul R. Tagliamonte 2013-03-24 10:00:07 -04:00
parent dd6a883060
commit ccd26205d7
2 changed files with 10 additions and 20 deletions

View File

@ -309,16 +309,6 @@ class HyASTCompiler(object):
fn.decorator_list = [self.compile(x) for x in expr]
return fn
@builds("with")
def compile_with_expression(self, expr):
expr.pop(0) # with
return ast.With(context_expr=self.compile(expr.pop(0)),
lineno=expr.start_line,
col_offset=expr.start_column,
optional_vars=None,
body=self._mangle_branch([
self.compile(x) for x in expr]))
@builds("with_as")
def compile_with_as_expression(self, expr):
expr.pop(0) # with-as
@ -326,15 +316,17 @@ class HyASTCompiler(object):
thing = self.compile(expr.pop(0))
thing.ctx = ast.Store()
# Module(body=[With(items=[withitem(context_expr=Name(id='foo', ctx=Load()), optional_vars=Name(id='e', ctx=Store()))], body=[Pass()])])
# Module(body=[With(context_expr=Name(id='foo', ctx=Load()), optional_vars=Name(id='e', ctx=Store()), body=[Pass()])])
ret = ast.With(context_expr=ctx,
lineno=expr.start_line,
col_offset=expr.start_column,
optional_vars=thing,
body=self._mangle_branch([
self.compile(x) for x in expr]))
return ast.With(context_expr=ctx,
lineno=expr.start_line,
col_offset=expr.start_column,
optional_vars=thing,
body=self._mangle_branch([
self.compile(x) for x in expr]))
if sys.version_info[0] >= 3 and sys.version_info[1] >= 3:
ret.items = [ast.withitem(context_expr=ctx, optional_vars=thing)]
return ret
@builds("kwapply")
def compile_kwapply_expression(self, expr):

View File

@ -198,7 +198,5 @@
(defn test-context []
"NATIVE: test with"
(with (open "README.md" "r")
(pass))
(with-as (open "README.md" "r") fd
(pass)))