1.1 --- a/compiler/ast.py Sun Feb 26 14:29:36 2017 +0100
1.2 +++ b/compiler/ast.py Sun Feb 26 21:47:56 2017 +0100
1.3 @@ -1592,38 +1592,6 @@
1.4 self.else_ and "\nelse:%s" % indent("\n%s" % self.else_) or ""
1.5 )
1.6
1.7 -class With(Node):
1.8 - def __init__(self, expr, vars, body, lineno=None):
1.9 - self.expr = expr
1.10 - self.vars = vars
1.11 - self.body = body
1.12 - self.lineno = lineno
1.13 -
1.14 - def getChildren(self):
1.15 - children = []
1.16 - children.append(self.expr)
1.17 - children.append(self.vars)
1.18 - children.append(self.body)
1.19 - return tuple(children)
1.20 -
1.21 - def getChildNodes(self):
1.22 - nodelist = []
1.23 - nodelist.append(self.expr)
1.24 - if self.vars is not None:
1.25 - nodelist.append(self.vars)
1.26 - nodelist.append(self.body)
1.27 - return tuple(nodelist)
1.28 -
1.29 - def __repr__(self):
1.30 - return "With(%r, %r, %r)" % (self.expr, self.vars, self.body)
1.31 -
1.32 - def __str__(self):
1.33 - return "with %s%s:%s" % (
1.34 - self.expr,
1.35 - self.vars and " as %s" % ", ".join(map(str, self.vars)),
1.36 - indent("\n%s" % self.body),
1.37 - )
1.38 -
1.39 for name, obj in globals().items():
1.40 if isinstance(obj, type) and issubclass(obj, Node):
1.41 nodes[name.lower()] = obj
2.1 --- a/compiler/transformer.py Sun Feb 26 14:29:36 2017 +0100
2.2 +++ b/compiler/transformer.py Sun Feb 26 21:47:56 2017 +0100
2.3 @@ -468,9 +468,6 @@
2.4 def try_stmt(self, nodelist):
2.5 return self.com_try_except_finally(nodelist)
2.6
2.7 - def with_stmt(self, nodelist):
2.8 - return self.com_with(nodelist)
2.9 -
2.10 def suite(self, nodelist):
2.11 # simple_stmt | NEWLINE INDENT NEWLINE* (stmt NEWLINE*)+ DEDENT
2.12 if len(nodelist) == 1:
2.13 @@ -874,24 +871,6 @@
2.14 else:
2.15 return try_except
2.16
2.17 - def com_with(self, nodelist):
2.18 - # with_stmt: 'with' with_item (',' with_item)* ':' suite
2.19 - body = self.com_node(nodelist[-1])
2.20 - for i in range(len(nodelist) - 3, 0, -2):
2.21 - ret = self.com_with_item(nodelist[i], body, nodelist[0][2])
2.22 - if i == 1:
2.23 - return ret
2.24 - body = ret
2.25 -
2.26 - def com_with_item(self, nodelist, body, lineno):
2.27 - # with_item: test ['as' expr]
2.28 - if len(nodelist) == 4:
2.29 - var = self.com_assign(nodelist[3], OP_ASSIGN)
2.30 - else:
2.31 - var = None
2.32 - expr = self.com_node(nodelist[1])
2.33 - return With(expr, var, body, lineno=lineno)
2.34 -
2.35 def com_augassign_op(self, node):
2.36 assert node[0] == symbol["augassign"]
2.37 return node[1]
2.38 @@ -1268,7 +1247,6 @@
2.39 symbol["while_stmt"],
2.40 symbol["for_stmt"],
2.41 symbol["try_stmt"],
2.42 - symbol["with_stmt"],
2.43 symbol["suite"],
2.44 symbol["testlist"],
2.45 symbol["testlist_safe"],
3.1 --- a/pyparser/data/Grammar-Lichen Sun Feb 26 14:29:36 2017 +0100
3.2 +++ b/pyparser/data/Grammar-Lichen Sun Feb 26 21:47:56 2017 +0100
3.3 @@ -48,7 +48,7 @@
3.4 exec_stmt: 'exec' expr ['in' test [',' test]]
3.5 assert_stmt: 'assert' test [',' test]
3.6
3.7 -compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | with_stmt | funcdef | classdef
3.8 +compound_stmt: if_stmt | while_stmt | for_stmt | try_stmt | funcdef | classdef
3.9 if_stmt: 'if' test ':' suite ('elif' test ':' suite)* ['else' ':' suite]
3.10 while_stmt: 'while' test ':' suite ['else' ':' suite]
3.11 for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite]
3.12 @@ -57,8 +57,6 @@
3.13 ['else' ':' suite]
3.14 ['finally' ':' suite] |
3.15 'finally' ':' suite))
3.16 -with_stmt: 'with' with_item (',' with_item)* ':' suite
3.17 -with_item: test ['as' expr]
3.18 # NB compile.c makes sure that the default except clause is last
3.19 except_clause: 'except' [test [('as' | ',') test]]
3.20 suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT