Skip to content

Commit 0870d13

Browse files
committed
prepare_report.py: Read/write files in binary mode to preserve line endings on Windows
1 parent ea08ab5 commit 0870d13

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

scripts/bytecodecompare/prepare_report.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ def format_report(self) -> str:
5555

5656

5757
def load_source(path: Union[Path, str]) -> str:
58-
with open(path, mode='r', encoding='utf8') as source_file:
58+
# NOTE: With newline='' is a special value to handle all newline styles but keep them untranslated.
59+
with open(path, mode='r', encoding='utf8', newline='') as source_file:
5960
file_content = source_file.read()
6061

6162
return file_content
@@ -193,7 +194,8 @@ def run_compiler(
193194

194195
# Create a copy that we can use directly with the CLI interface
195196
modified_source_path = tmp_dir / source_file_name.name
196-
with open(modified_source_path, 'w', encoding='utf8') as modified_source_file:
197+
# NOTE: With newline='' is a special value to handle all newline styles but keep them untranslated.
198+
with open(modified_source_path, 'w', encoding='utf8', newline='') as modified_source_file:
197199
modified_source_file.write(compiler_input)
198200

199201
process = subprocess.run(

0 commit comments

Comments
 (0)