Browse Source

Intermediate changes

robot-piglet 9 months ago
parent
commit
f448208220
1 changed files with 4 additions and 1 deletions
  1. 4 1
      library/python/fs/__init__.py

+ 4 - 1
library/python/fs/__init__.py

@@ -290,7 +290,10 @@ def copy_tree(src, dst, copy_function=shutil.copy2):
 # Throws OSError
 # Throws OSError
 @errorfix_win
 @errorfix_win
 def read_file(path, binary=True):
 def read_file(path, binary=True):
-    with open(path, 'r' + ('b' if binary else '')) as f:
+    kwargs = {}
+    if not binary and six.PY3:
+        kwargs['encoding'] = sys.getfilesystemencoding()
+    with open(path, 'r' + ('b' if binary else ''), **kwargs) as f:
         return f.read()
         return f.read()