diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-09-03 01:06:52 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-09-03 01:06:52 +0000 |
commit | 295e070566dd89f38fe3a8450a06c5f97f839fc4 (patch) | |
tree | c179129d17d7fa01ce90c1a37df9c5d5a9d0b053 | |
parent | 1041841565de4f4348de5fbd7792eb8b375493c1 (diff) | |
download | portage-295e070566dd89f38fe3a8450a06c5f97f839fc4.tar.gz portage-295e070566dd89f38fe3a8450a06c5f97f839fc4.tar.bz2 portage-295e070566dd89f38fe3a8450a06c5f97f839fc4.zip |
Use _unicode_decode() on the string retunred from time.strftime(), in order
to avoid a potential UnicodeDecodeError later. Thanks to Markus Duft
<mduft@gentoo.org> for reporting.
svn path=/main/trunk/; revision=14180
-rw-r--r-- | pym/portage/elog/mod_save_summary.py | 8 |
1 files changed, 7 insertions, 1 deletions
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() |