file must be open in text mode

those files must be opened in text mode in python3
This commit is contained in:
MirceaDan committed 2018-12-01 16:36:11 -08:00
1 parent a5cff5bc3d
commit 347f53baa4
3 files changed
+7 -19

No files matched your search

+1 -1
View File
@@ -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("#")]
+4 -12
View File
@@ -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")
+2 -6
View File
@@ -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