compiler: fix ARTIQ_DUMP_ELF.

This commit is contained in:
whitequark 2016-03-29 13:02:14 +00:00 committed by Sebastien Bourdeauducq
parent 812e79b63d
commit f7603dcb6f
1 changed files with 4 additions and 2 deletions

View File

@ -46,12 +46,14 @@ class RunTool:
def _dump(target, kind, suffix, content): def _dump(target, kind, suffix, content):
if target is not None: if target is not None:
print("====== {} DUMP ======".format(kind.upper()), file=sys.stderr) print("====== {} DUMP ======".format(kind.upper()), file=sys.stderr)
content_bytes = bytes(content(), 'utf-8') content_value = content()
if isinstance(content_value, str):
content_value = bytes(content_value, 'utf-8')
if target == "": if target == "":
file = tempfile.NamedTemporaryFile(suffix=suffix, delete=False) file = tempfile.NamedTemporaryFile(suffix=suffix, delete=False)
else: else:
file = open(target + suffix, "wb") file = open(target + suffix, "wb")
file.write(content_bytes) file.write(content_value)
file.close() file.close()
print("{} dumped as {}".format(kind, file.name), file=sys.stderr) print("{} dumped as {}".format(kind, file.name), file=sys.stderr)