diff options
author | Alessio Sergi <al3hex@gmail.com> | 2013-10-30 13:03:00 +0100 |
---|---|---|
committer | Alessio Sergi <al3hex@gmail.com> | 2013-10-30 13:03:00 +0100 |
commit | 9a8552eb3fd3ed1474876650d594bb11a03c2a29 (patch) | |
tree | b34d7c7e7bd57046aa114d193d8da815aa4c828b /glances/glances.py | |
parent | 6c5b640e2f198256f2e2179f38874f381e92a555 (diff) |
UTF-8 config file for python 3 [issue #295]
Diffstat (limited to 'glances/glances.py')
-rw-r--r-- | glances/glances.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/glances/glances.py b/glances/glances.py index 93b88cb6..8845baf0 100644 --- a/glances/glances.py +++ b/glances/glances.py @@ -387,7 +387,15 @@ class Config: """ for path in self.get_paths_list(): if os.path.isfile(path) and os.path.getsize(path) > 0: - self.parser.read(path) + try: + if sys.version_info >= (3, 2): + self.parser.read(path, encoding='utf-8') + else: + self.parser.read(path) + except UnicodeDecodeError as e: + print(_("Error decoding config file '%s': %s") % (path, e)) + sys.exit(1) + break def get_paths_list(self): |