diff --git a/hy/compiler.py b/hy/compiler.py index 69d307c..23db815 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -692,8 +692,9 @@ class HyASTCompiler(object): expr.pop(0) ret = self.compile(HyExpression( - [HySymbol("hy_eval")] + expr + [HyExpression([HySymbol("locals")])] - + [HyString(self.module_name)]).replace(expr) + [HySymbol("hy_eval")] + expr + + [HyExpression([HySymbol("locals")])] + + [HyString(self.module_name)]).replace(expr) ) ret.add_imports("hy.importer", ["hy_eval"]) diff --git a/hy/completer.py b/hy/completer.py index ea813c5..eaac593 100644 --- a/hy/completer.py +++ b/hy/completer.py @@ -25,11 +25,15 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +import contextlib import os import re import sys -from contextlib import contextmanager -from hy._compat import string_types + +import hy.macros +import hy.compiler +from hy._compat import builtins, string_types + docomplete = True @@ -49,12 +53,6 @@ else: readline_bind = "tab: complete" -import hy.macros -import hy.compiler - -from hy._compat import builtins - - class Completer(object): def __init__(self, namespace={}): @@ -129,7 +127,7 @@ class Completer(object): return None -@contextmanager +@contextlib.contextmanager def completion(completer=None): delims = "()[]{} " if not completer: diff --git a/tests/compilers/test_compiler.py b/tests/compilers/test_compiler.py index 7297f26..59801cd 100644 --- a/tests/compilers/test_compiler.py +++ b/tests/compilers/test_compiler.py @@ -22,16 +22,16 @@ import ast import sys -if sys.version_info[0] <= 2 and sys.version_info[1] <= 6: - import unittest2 as unittest -else: - import unittest - from hy import compiler from hy.models.expression import HyExpression from hy.models.list import HyList from hy.models.symbol import HySymbol +if sys.version_info[0] <= 2 and sys.version_info[1] <= 6: + import unittest2 as unittest +else: + import unittest + class CompilerTest(unittest.TestCase): diff --git a/tests/test_bin.py b/tests/test_bin.py index 74561aa..6436fa5 100644 --- a/tests/test_bin.py +++ b/tests/test_bin.py @@ -136,8 +136,7 @@ def test_hy2py(): continue else: i += 1 - ret = run_cmd("hy2py -s -a " - + os.path.join(dirpath, f)) + ret = run_cmd("hy2py -s -a " + os.path.join(dirpath, f)) assert ret[0] == 0, f assert len(ret[1]) > 1, f assert len(ret[2]) == 0, f