From 295e070566dd89f38fe3a8450a06c5f97f839fc4 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 3 Sep 2009 01:06:52 +0000 Subject: [PATCH] Use _unicode_decode() on the string retunred from time.strftime(), in order to avoid a potential UnicodeDecodeError later. Thanks to Markus Duft for reporting. svn path=/main/trunk/; revision=14180 --- pym/portage/elog/mod_save_summary.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pym/portage/elog/mod_save_summary.py b/pym/portage/elog/mod_save_summary.py index f35c71c83..9aeb89fc9 100644 --- a/pym/portage/elog/mod_save_summary.py +++ b/pym/portage/elog/mod_save_summary.py @@ -7,6 +7,7 @@ import codecs import time from portage import os from portage import _encodings +from portage import _unicode_decode from portage import _unicode_encode from portage.data import portage_uid, portage_gid from portage.localization import _ @@ -25,8 +26,13 @@ def process(mysettings, key, logentries, fulltext): encoding=_encodings['fs'], errors='strict'), mode='a', encoding=_encodings['content'], errors='backslashreplace') apply_permissions(elogfilename, mode=060, mask=0) + time_str = time.strftime("%Y-%m-%d %H:%M:%S %Z", + time.localtime(time.time())) + # Avoid potential UnicodeDecodeError later. + time_str = _unicode_decode(time_str, + encoding=_encodings['content'], errors='replace') elogfile.write(_(">>> Messages generated by process %(pid)d on %(time)s for package %(pkg)s:\n\n") % - {"pid": os.getpid(), "time": time.strftime("%Y-%m-%d %H:%M:%S %Z", time.localtime(time.time())), "pkg": key}) + {"pid": os.getpid(), "time": time_str, "pkg": key}) elogfile.write(fulltext) elogfile.write("\n") elogfile.close() -- 2.26.2