From b36294336572d6c4238613bf5be3288192d40fd3 Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Tue, 11 Aug 2015 10:43:00 +0200 Subject: [PATCH] compiler: Fix the kw argument needs value exception Strip the \ufdd0 prefix from the keyword argument before turning it into a string: the same representation the user entered looks better, and is printable too, thus Python2 doesn't choke on it. Signed-off-by: Gergely Nagy --- hy/compiler.py | 2 +- tests/compilers/test_ast.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hy/compiler.py b/hy/compiler.py index 05a2fd5..41119f1 100644 --- a/hy/compiler.py +++ b/hy/compiler.py @@ -461,7 +461,7 @@ class HyASTCompiler(object): except StopIteration: raise HyTypeError(expr, "Keyword argument {kw} needs " - "a value.".format(kw=str(expr))) + "a value.".format(kw=str(expr[1:]))) compiled_value = self.compile(value) ret += compiled_value diff --git a/tests/compilers/test_ast.py b/tests/compilers/test_ast.py index 633c3bb..dd6ae59 100644 --- a/tests/compilers/test_ast.py +++ b/tests/compilers/test_ast.py @@ -444,7 +444,7 @@ def test_missing_keyword_argument_value(): try: can_compile("((fn [x] x) :x)") except HyTypeError as e: - assert(e.message == "Keyword argument \ufdd0:x needs a value.") + assert(e.message == "Keyword argument :x needs a value.") else: assert(False)