about summary refs log tree commit diff stats
path: root/ranger
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
commitcec7bd50aa61eabd1cd8b1da2f2c2115e7b23662 (patch)
tree8ea56af9646dae4e646301a8ee7e659dc75686c0 /ranger
parent08ab6b9fd3c2beada39951576ebf017d5a65f3f7 (diff)
downloadranger-cec7bd50aa61eabd1cd8b1da2f2c2115e7b23662.tar.gz
main: Force UTF-8 encoding
Diffstat (limited to 'ranger')
-rw-r--r--ranger/core/main.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/ranger/core/main.py b/ranger/core/main.py
index cf058163..2556b22a 100644
--- a/ranger/core/main.py
+++ b/ranger/core/main.py
@@ -75,7 +75,9 @@ def main(
             return 1
         fm = FM()
         try:
-            with open(fm.datapath('tagged'), 'r', errors='replace') as fobj:
+            with open(
+                fm.datapath('tagged'), 'r', encoding="utf-8", errors='replace'
+            ) as fobj:
                 lines = fobj.readlines()
         except OSError as ex:
             print('Unable to open `tagged` data file: {0}'.format(ex), file=sys.stderr)
@@ -156,11 +158,11 @@ def main(
             tabs_datapath = fm.datapath('tabs')
             if fm.settings.save_tabs_on_exit and os.path.exists(tabs_datapath) and not args.paths:
                 try:
-                    with open(tabs_datapath, 'r') as fobj:
+                    with open(tabs_datapath, 'r', encoding="utf-8") as fobj:
                         tabs_saved = fobj.read().partition('\0\0')
                         fm.start_paths += tabs_saved[0].split('\0')
                     if tabs_saved[-1]:
-                        with open(tabs_datapath, 'w') as fobj:
+                        with open(tabs_datapath, 'w', encoding="utf-8") as fobj:
                             fobj.write(tabs_saved[-1])
                     else:
                         os.remove(tabs_datapath)
@@ -443,7 +445,9 @@ def load_settings(  # pylint: disable=too-many-locals,too-many-branches,too-many
 
             if not os.path.exists(fm.confpath('plugins', '__init__.py')):
                 LOG.debug("Creating missing '__init__.py' file in plugin folder")
-                with open(fm.confpath('plugins', '__init__.py'), 'w'):
+                with open(
+                    fm.confpath('plugins', '__init__.py'), 'w', encoding="utf-8"
+                ):
                     # Create the file if it doesn't exist.
                     pass