diff options
author | mathieui <mathieui@mathieui.net> | 2018-01-13 15:29:23 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2018-01-13 15:29:23 +0100 |
commit | 391eb279640ea9250f5d16d44c4691a5b7d4efc1 (patch) | |
tree | 4dbfe20c6e8493b620f72e36abbcfde8d9dde8b2 | |
parent | b981327df58eac0cf41a206333bf36dd5c4e2330 (diff) | |
download | poezio-391eb279640ea9250f5d16d44c4691a5b7d4efc1.tar.gz poezio-391eb279640ea9250f5d16d44c4691a5b7d4efc1.tar.bz2 poezio-391eb279640ea9250f5d16d44c4691a5b7d4efc1.tar.xz poezio-391eb279640ea9250f5d16d44c4691a5b7d4efc1.zip |
Open and write logs and config files in utf-8
-rw-r--r-- | poezio/config.py | 3 | ||||
-rw-r--r-- | poezio/logger.py | 7 |
2 files changed, 6 insertions, 4 deletions
diff --git a/poezio/config.py b/poezio/config.py index 7ac630b6..08920942 100644 --- a/poezio/config.py +++ b/poezio/config.py @@ -337,7 +337,8 @@ class Config(RawConfigParser): prefix, file = path.split(self.file_name) filename = path.join(prefix, '.%s.tmp' % file) fd = os.fdopen( - os.open(filename, os.O_WRONLY | os.O_CREAT, 0o600), 'w') + os.open(filename, os.O_WRONLY | os.O_CREAT, 0o600,), 'w', + encoding='utf-8') for line in lines: fd.write('%s\n' % line) fd.close() diff --git a/poezio/logger.py b/poezio/logger.py index d2e2214f..8eff0209 100644 --- a/poezio/logger.py +++ b/poezio/logger.py @@ -122,7 +122,7 @@ class Logger(object): if not open_fd: return try: - fd = open(os.path.join(log_dir, room), 'a') + fd = open(os.path.join(log_dir, room), 'a', encoding='utf-8') self._fds[room] = fd return fd except IOError: @@ -150,7 +150,7 @@ class Logger(object): self._check_and_create_log_dir(jid, open_fd=False) try: - fd = open(os.path.join(log_dir, jid), 'rb') + fd = open(os.path.join(log_dir, jid), 'rb', encoding='utf-8') except FileNotFoundError: log.info( 'Non-existing log file (%s)', @@ -228,7 +228,8 @@ class Logger(object): if not self._roster_logfile: try: self._roster_logfile = open( - os.path.join(log_dir, 'roster.log'), 'a') + os.path.join(log_dir, 'roster.log'), 'a', + encoding='utf-8') except IOError: log.error( 'Unable to create the log file (%s)', |