Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Windows compatibility #134

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion codegen/x86_64.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,7 @@ def is_label_branch(instruction_form):

def main(package_root="."):
for group, instruction_names in six.iteritems(instruction_groups):
with open(os.path.join(package_root, "peachpy", "x86_64", group + ".py"), "w") as out:
with open(os.path.join(package_root, "peachpy", "x86_64", group + ".py"), "w", encoding="utf-8") as out:
with CodeWriter() as code:
code.line("# This file is auto-generated by /codegen/x86_64.py")
code.line("# Instruction data is based on package opcodes %s" % opcodes.__version__)
Expand Down
2 changes: 1 addition & 1 deletion peachpy/arm/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def __exit__(self, exc_type, exc_value, traceback):
self.determine_live_registers(exclude_parameter_loads=True)

if self.dump_intermediate_assembly:
with open('%s.S' % self.symbol_name, "w") as intermediate_assembly_file:
with open('%s.S' % self.symbol_name, "w", encoding="utf-8") as intermediate_assembly_file:
for instruction in self.instructions:
if isinstance(instruction, Instruction):
consumed_registers = ", ".join(sorted(map(str, list(instruction.get_input_registers_list()))))
Expand Down
4 changes: 3 additions & 1 deletion peachpy/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, output_path):
def __enter__(self):
global active_writers
active_writers.append(self)
self.output_file = open(self.output_path, "w")
self.output_file = open(self.output_path, "w", encoding="utf-8")
return self

def __exit__(self, exc_type, exc_value, traceback):
Expand All @@ -27,6 +27,7 @@ def __exit__(self, exc_type, exc_value, traceback):
self.output_file = None
else:
import os
self.output_file.close()
os.unlink(self.output_file.name)
self.output_file = None
raise
Expand Down Expand Up @@ -110,6 +111,7 @@ def __exit__(self, exc_type, exc_value, traceback):
self.output_file = None
else:
import os
self.output_file.close()
os.unlink(self.output_file.name)
self.output_file = None
raise
Expand Down
4 changes: 2 additions & 2 deletions peachpy/x86_64/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def main():
if options.dependencies_makefile_path:
dependencies_makefile_path = options.dependencies_makefile_path
if options.rtl_dump:
peachpy.x86_64.options.rtl_dump_file = open(options.rtl_dump, "w")
peachpy.x86_64.options.rtl_dump_file = open(options.rtl_dump, "w", encoding="utf-8")
if options.c_header_file:
writers.append(CHeaderWriter(options.c_header_file, options.input[0]))
if options.json_metadata_file:
Expand All @@ -275,7 +275,7 @@ def main():

dependencies = list(sorted(module_files))
dependencies.insert(0, options.input[0])
with open(dependencies_makefile_path, "w") as dependencies_makefile:
with open(dependencies_makefile_path, "w", encoding="utf-8") as dependencies_makefile:
dependencies_makefile.write(options.output + ": \\\n " + " \\\n ".join(dependencies) + "\n")

if __name__ == "__main__":
Expand Down