about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authortoonn <toonn@toonn.io>2021-09-01 17:53:15 +0200
committertoonn <toonn@toonn.io>2021-09-01 17:57:15 +0200
commitaa4502533cd0de6b82e8fa6851ddc5b4d3a310d1 (patch)
tree6e67dcb173c14ea0f6808a48b438de28a318c23b
parentdac6f0857c61afced54435cac23971c60ce77fd5 (diff)
downloadranger-aa4502533cd0de6b82e8fa6851ddc5b4d3a310d1.tar.gz
actions: Force UTF-8 encoding
-rw-r--r--ranger/core/actions.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py
index 784a6c09..a552e328 100644
--- a/ranger/core/actions.py
+++ b/ranger/core/actions.py
@@ -373,7 +373,7 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
         filename = os.path.expanduser(filename)
         LOG.debug("Sourcing config file '%s'", filename)
         # pylint: disable=unspecified-encoding
-        with open(filename, 'r') as fobj:
+        with open(filename, 'r', encoding="utf-8") as fobj:
             for line in fobj:
                 line = line.strip(" \r\n")
                 if line.startswith("#") or not line.strip():
@@ -405,7 +405,9 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
         # ranger can act as a file chooser when running with --choosefile=...
         if mode == 0 and 'label' not in kw:
             if ranger.args.choosefile:
-                with open(ranger.args.choosefile, 'w') as fobj:
+                with open(
+                    ranger.args.choosefile, 'w', encoding="utf-8"
+                ) as fobj:
                     fobj.write(self.fm.thisfile.path)
 
             if ranger.args.choosefiles:
@@ -416,7 +418,9 @@ class Actions(  # pylint: disable=too-many-instance-attributes,too-many-public-m
                             paths += [fobj.path]
                 paths += [f.path for f in self.fm.thistab.get_selection() if f.path not in paths]
 
-                with open(ranger.args.choosefiles, 'w') as fobj:
+                with open(
+                    ranger.args.choosefiles, 'w', encoding="utf-8"
+                ) as fobj:
                     fobj.write('\n'.join(paths) + '\n')
 
             if ranger.args.choosefile or ranger.args.choosefiles: