From 5f966b0b8d61e2abf003439b2f93a9bd19be798c Mon Sep 17 00:00:00 2001 From: Christoph Reiter Date: Sat, 7 Nov 2020 08:41:42 +0100 Subject: Always pass an encoding to open() using text mode Otherwise we'll end up using the locale encoding. While it's usually utf-8, that's not the case on Windows. There is one place where a file with filenames is passed, not sure there so I left it and passed a explicit None. --- tests/scanner/test_maintransformer.py | 2 +- tests/scanner/test_transformer.py | 2 +- tests/warn/warningtester.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/scanner/test_maintransformer.py b/tests/scanner/test_maintransformer.py index abf3ee73..f0e2d629 100644 --- a/tests/scanner/test_maintransformer.py +++ b/tests/scanner/test_maintransformer.py @@ -16,7 +16,7 @@ def create_scanner_from_source_string(source): tmp_fd, tmp_name = tempfile.mkstemp(suffix='.h', text=True) try: - with os.fdopen(tmp_fd, 'wt') as file: + with os.fdopen(tmp_fd, 'w', encoding='utf-8') as file: file.write(source) ss.parse_files([tmp_name]) finally: diff --git a/tests/scanner/test_transformer.py b/tests/scanner/test_transformer.py index c6fbf4e7..3feed441 100644 --- a/tests/scanner/test_transformer.py +++ b/tests/scanner/test_transformer.py @@ -18,7 +18,7 @@ def create_scanner_from_source_string(source): tmp_fd, tmp_name = tempfile.mkstemp(suffix='.h', text=True) try: - with os.fdopen(tmp_fd, 'wt') as file: + with os.fdopen(tmp_fd, 'w', encoding='utf-8') as file: file.write(source) ss.parse_files([tmp_name]) finally: diff --git a/tests/warn/warningtester.py b/tests/warn/warningtester.py index fedd3a59..3bb9e4b2 100644 --- a/tests/warn/warningtester.py +++ b/tests/warn/warningtester.py @@ -78,7 +78,7 @@ def _diff(a, b): def _extract_expected(filename): - fd = open(filename, 'r') + fd = open(filename, 'r', encoding='utf-8') data = fd.read() fd.close() -- cgit v1.2.1