misc. style fixes
This commit is contained in:
parent
7066d53b02
commit
55ed7cee62
@ -129,7 +129,7 @@ class HyASTCompiler(object):
|
|||||||
self.anon_fn_count = 0
|
self.anon_fn_count = 0
|
||||||
self.imports = defaultdict(list)
|
self.imports = defaultdict(list)
|
||||||
|
|
||||||
def being_returnable(self, v):
|
def is_returnable(self, v):
|
||||||
return temporary_attribute_value(self, "returnable", v)
|
return temporary_attribute_value(self, "returnable", v)
|
||||||
|
|
||||||
def compile(self, tree):
|
def compile(self, tree):
|
||||||
@ -954,7 +954,7 @@ class HyASTCompiler(object):
|
|||||||
@builds("foreach")
|
@builds("foreach")
|
||||||
@checkargs(min=1)
|
@checkargs(min=1)
|
||||||
def compile_for_expression(self, expression):
|
def compile_for_expression(self, expression):
|
||||||
with self.being_returnable(False):
|
with self.is_returnable(False):
|
||||||
expression.pop(0) # for
|
expression.pop(0) # for
|
||||||
name, iterable = expression.pop(0)
|
name, iterable = expression.pop(0)
|
||||||
target = self._storeize(self.compile_symbol(name))
|
target = self._storeize(self.compile_symbol(name))
|
||||||
@ -1019,14 +1019,14 @@ class HyASTCompiler(object):
|
|||||||
|
|
||||||
body = []
|
body = []
|
||||||
if expression != []:
|
if expression != []:
|
||||||
with self.being_returnable(True):
|
with self.is_returnable(True):
|
||||||
tailop = self.compile(expression.pop(-1))
|
tailop = self.compile(expression.pop(-1))
|
||||||
with self.being_returnable(False):
|
with self.is_returnable(False):
|
||||||
for el in expression:
|
for el in expression:
|
||||||
body.append(self.compile(el))
|
body.append(self.compile(el))
|
||||||
body.append(tailop)
|
body.append(tailop)
|
||||||
|
|
||||||
with self.being_returnable(True):
|
with self.is_returnable(True):
|
||||||
body = self._code_branch(body,
|
body = self._code_branch(body,
|
||||||
expression.start_line,
|
expression.start_line,
|
||||||
expression.start_column)
|
expression.start_column)
|
||||||
|
@ -34,7 +34,12 @@ def temporary_attribute_value(obj, attribute, value):
|
|||||||
"""Temporarily switch an object attribute value to another value."""
|
"""Temporarily switch an object attribute value to another value."""
|
||||||
original_value = getattr(obj, attribute)
|
original_value = getattr(obj, attribute)
|
||||||
setattr(obj, attribute, value)
|
setattr(obj, attribute, value)
|
||||||
|
|
||||||
|
try:
|
||||||
yield
|
yield
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
setattr(obj, attribute, original_value)
|
setattr(obj, attribute, original_value)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user