From f62d448c6eb6d484cd424a8af5f06282240c9cac Mon Sep 17 00:00:00 2001 From: Teddy Valette Date: Mon, 8 Jul 2019 14:35:00 +0200 Subject: [PATCH] Open csr_country_codes as a utf-8 file Prevent issues like : Jul 08 14:07:44 box.hostname.com systemd[1]: Started Mail-in-a-Box System Management Service. Jul 08 14:07:44 box.hostname.com start[13602]: Traceback (most recent call last): Jul 08 14:07:44 box.hostname.com start[13602]: File "/root/mailinabox/management/daemon.py", line 27, in Jul 08 14:07:44 box.hostname.com start[13602]: for line in f: Jul 08 14:07:44 box.hostname.com start[13602]: File "/usr/local/lib/mailinabox/env/lib/python3.6/encodings/ascii.py Jul 08 14:07:44 box.hostname.com start[13602]: return codecs.ascii_decode(input, self.errors)[0] Jul 08 14:07:44 box.hostname.com start[13602]: UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 7 Jul 08 14:07:44 box.hostname.com systemd[1]: mailinabox.service: Main process exited, code=exited, status=1/FAILURE Jul 08 14:07:44 box.hostname.com systemd[1]: mailinabox.service: Failed with result 'exit-code'. --- management/daemon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/management/daemon.py b/management/daemon.py index 572b6b4a..5329748d 100755 --- a/management/daemon.py +++ b/management/daemon.py @@ -23,7 +23,7 @@ except OSError: # for generating CSRs we need a list of country codes csr_country_codes = [] -with open(os.path.join(os.path.dirname(me), "csr_country_codes.tsv")) as f: +with open(os.path.join(os.path.dirname(me), "csr_country_codes.tsv"), encoding="utf-8") as f: for line in f: if line.strip() == "" or line.startswith("#"): continue code, name = line.strip().split("\t")[0:2]