diff --git a/src/octoprint/_version.py b/src/octoprint/_version.py index 9616fb06b..d30901e18 100644 --- a/src/octoprint/_version.py +++ b/src/octoprint/_version.py @@ -307,7 +307,7 @@ def git_parse_lookup_file(path): return [] lookup = [] - with io.open(path, 'rb') as f: + with io.open(path, 'rt', encoding='utf-8') as f: for line in f: if '#' in line: line = line[:line.rindex("#")] diff --git a/tests/settings/test_settings.py b/tests/settings/test_settings.py index d96acec9b..dfcf87612 100644 --- a/tests/settings/test_settings.py +++ b/tests/settings/test_settings.py @@ -27,20 +27,12 @@ import octoprint.settings class TestSettings(unittest.TestCase): def _load_yaml(self, fname): - if sys.version_info[0] >= 3: - with io.open(fname, 'r+b', encoding='utf-8') as f: - return yaml.safe_load(f) - else: - with io.open(fname, 'r+b') as f: - return yaml.safe_load(f) + with io.open(fname, 'rt+', encoding='utf-8') as f: + return yaml.safe_load(f) def _dump_yaml(self, fname, config): - if sys.version_info[0] >= 3: - with io.open(fname, 'w+', encoding='utf-8') as f: - yaml.safe_dump(config, f) - else: - with io.open(fname, 'wb+') as f: - yaml.safe_dump(config, f) + with io.open(fname, 'wt+', encoding='utf-8') as f: + yaml.safe_dump(config, f) def setUp(self): self.base_path = os.path.join(os.path.dirname(__file__), "_files") diff --git a/tests/util/test_file_helpers.py b/tests/util/test_file_helpers.py index 9c2e38374..d2576c012 100644 --- a/tests/util/test_file_helpers.py +++ b/tests/util/test_file_helpers.py @@ -336,12 +336,8 @@ class IsHiddenPathTest(unittest.TestCase): import sys for attr in ("path_always_visible", "path_hidden_on_windows", "path_always_hidden"): path = getattr(self, attr) - if sys.version_info[0] >= 3: - with io.open(path, 'w+b', encoding='utf-8') as f: - f.write(attr) - else: - with io.open(path, 'wb+') as f: - f.write(attr) + with io.open(path, 'wt+', encoding='utf-8') as f: + f.write(attr) if sys.platform == "win32": # we use ctypes and the windows API to set the hidden attribute on the file