From: Zac Medico Date: Tue, 4 Aug 2009 18:26:27 +0000 (-0000) Subject: Open log files in text mode (to avoid UnicodeEncodeError). Thanks to Markos X-Git-Tag: v2.2_rc36~16 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fad324877f76279dcd9efa5dac07bc97841329b1;p=portage.git Open log files in text mode (to avoid UnicodeEncodeError). Thanks to Markos Chandras for reporting. svn path=/main/trunk/; revision=13901 --- diff --git a/pym/_emerge/Scheduler.py b/pym/_emerge/Scheduler.py index 9228ab6f4..0ad91675f 100644 --- a/pym/_emerge/Scheduler.py +++ b/pym/_emerge/Scheduler.py @@ -2,6 +2,7 @@ # Distributed under the terms of the GNU General Public License v2 # $Id$ +import codecs import logging import os import sys @@ -476,7 +477,8 @@ class Scheduler(PollScheduler): return self._pkg(cpv, type_name, root_config, installed=installed) def _append_to_log_path(self, log_path, msg): - f = open(log_path, 'a') + f = codecs.open(log_path, mode='a', + encoding='utf_8', errors='replace') try: f.write(msg) finally: @@ -490,7 +492,8 @@ class Scheduler(PollScheduler): background = self._background if background and log_path is not None: - log_file = open(log_path, 'a') + log_file = codecs.open(log_path, mode='a', + encoding='utf_8', errors='replace') out = log_file try: @@ -865,7 +868,8 @@ class Scheduler(PollScheduler): log_path = self._locate_failure_log(failed_pkg) if log_path is not None: try: - log_file = open(log_path) + log_file = codecs.open(log_path, mode='r', + encoding='utf_8', errors='replace') except IOError: pass