From b1c605cc6abb125821d67cd77b30683cb1b53036 Mon Sep 17 00:00:00 2001 From: "Paul R. Tagliamonte" Date: Mon, 1 Apr 2013 23:06:59 -0400 Subject: [PATCH] Updating the tests to not break Python 3.x --- hy/compiler.py | 6 ++++-- tests/native_tests/language.hy | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index 92c611a..bf7e136 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -166,11 +166,13 @@ class HyASTCompiler(object): @builds("print") def compile_print_expression(self, expr): - expr.pop(0) # print + call = expr.pop(0) # print if sys.version_info[0] >= 3: + call = self.compile(call) # AST changed with Python 3, we now just call it. return ast.Call( - func=ast.Name(id='print', ctx=ast.Load()), + keywords=[], + func=call, args=[self.compile(x) for x in expr], lineno=expr.start_line, col_offset=expr.start_column) diff --git a/tests/native_tests/language.hy b/tests/native_tests/language.hy index 62291f9..8c318d6 100644 --- a/tests/native_tests/language.hy +++ b/tests/native_tests/language.hy @@ -206,4 +206,5 @@ "NATIVE: test list comprehensions" (assert (= (list-comp (* x 2) (x (range 2))) [0 2])) (assert (= (list-comp (* x 2) (x (range 4)) (% x 2)) [2 6])) - (assert (= (list-comp (* y 2) ((, x y) (.iteritems {"1" 1 "2" 2}))) [2 4]))) + (assert (= (sorted (list-comp (* y 2) ((, x y) (.items {"1" 1 "2" 2})))) + [2 4])))