From 9df508f7c0e3bba40e64431ff030df64a8e6f107 Mon Sep 17 00:00:00 2001 From: Siu Kwan Lam Date: Wed, 27 Feb 2013 18:43:57 -0600 Subject: [PATCH] Fix test with unicode problem in py3k --- llvm/test_llvmpy.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/llvm/test_llvmpy.py b/llvm/test_llvmpy.py index 04170b4..02bb386 100644 --- a/llvm/test_llvmpy.py +++ b/llvm/test_llvmpy.py @@ -10,6 +10,7 @@ import subprocess import tempfile import contextlib +is_py3k = sys.version_info[0] >= 3 BITS = tuple.__itemsize__ * 8 try: @@ -711,7 +712,10 @@ class TestNative(TestCase): src = os.path.join(self.tmpdir, 'llvmasm.s') with open(src, 'wb') as fout: - fout.write(output) + if is_py3k: + fout.write(output.encode('utf-8')) + else: + fout.write(output) self._compile(src) @@ -725,7 +729,11 @@ class TestNative(TestCase): src = os.path.join(self.tmpdir, 'llvmobj.o') with open(src, 'wb') as fout: - fout.write(output) + if is_py3k: + fout.write(output.encode('utf-8')) + else: + fout.write(output) + self._compile(src) @@ -965,7 +973,7 @@ class TestCPUSupport(TestCase): features = [] from llvm.workaround.avx_support import detect_avx_support if not detect_avx_support(): - print 'Skipping: no AVX' + print('Skipping: no AVX') else: mattrs = ','.join(map(lambda s: '-%s' % s, features)) print('disable mattrs', mattrs)