diff --git a/aheui/aheui.py b/aheui/aheui.py index b2276c8..e399dda 100644 --- a/aheui/aheui.py +++ b/aheui/aheui.py @@ -454,7 +454,8 @@ def prepare_compiler(contents, opt_level=2, source='code', aheuic_output=None, a elif source == 'asm': compiler.read_asm(contents.decode('utf-8')) else: - compiler.compile(contents.decode('utf-8'), add_debug_info=add_debug_info) + contents = contents.decode('utf-8') + compiler.compile(contents, add_debug_info=add_debug_info) if opt_level == 0: pass diff --git a/aheui/option.py b/aheui/option.py index 676dec0..aff6e5f 100644 --- a/aheui/option.py +++ b/aheui/option.py @@ -4,7 +4,7 @@ import os from aheui._argparse import ArgumentParser -from aheui._compat import bigint +from aheui._compat import bigint, PY3 from aheui.version import VERSION from aheui import compile @@ -89,6 +89,8 @@ def open_r(filename): if len(args) != 1: os.write(2, b'aheui: error: --cmd,-c but input file found\n') raise SystemExit() + if PY3: + cmd = cmd.encode('utf-8') contents = cmd filename = '-' @@ -100,7 +102,7 @@ def open_r(filename): source = 'bytecode' elif filename.endswith('.aheuis'): source = 'asm' - elif '\xff\xff\xff\xff' in contents: + elif b'\xff\xff\xff\xff' in contents: source = 'bytecode' else: source = 'text'