[yum-commits] yum/Errors.py
zpavlas at osuosl.org
zpavlas at osuosl.org
Fri May 17 14:50:47 UTC 2013
yum/Errors.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
New commits:
commit 0f0d069c1263f9ec16dca01e1f02a8b5c5f3c56d
Author: Zdenek Pavlas <zpavlas at redhat.com>
Date: Fri May 17 08:51:29 2013 +0200
YumBaseError: safe str(e). BZ 963698
PackageKit tries to log a YumBaseError instance with:
self.error(ERROR_MISSING_GPG_SIGNATURE, _to_unicode(e), exit=False)
However, _to_unicode() only converts utf8 strings to unicode,
and is a no-op for exception instances. The logger module then
tries to convert e to str, and str(e) fails, since e.__str__()
returns unicode. I think str(e) should not traceback.
test with:
>>> import yum.Errors
>>> e = yum.Errors.YumBaseError(u'ÄÅ¡Ä')
>>> unicode(e) # worked already
u'\u011b\u0161\u010d'
>>> str(e) # this used to fail
'\xc4\x9b\xc5\xa1\xc4\x8d'
diff --git a/yum/Errors.py b/yum/Errors.py
index e3e3956..70de539 100644
--- a/yum/Errors.py
+++ b/yum/Errors.py
@@ -18,7 +18,7 @@
Exceptions and Errors thrown by yum.
"""
-from i18n import to_unicode
+from i18n import to_unicode, to_utf8
class YumBaseError(Exception):
"""
@@ -29,7 +29,7 @@ class YumBaseError(Exception):
Exception.__init__(self)
self.value = value
def __str__(self):
- return "%s" %(self.value,)
+ return "%s" % to_utf8(self.value)
def __unicode__(self):
return '%s' % to_unicode(self.value)
More information about the Yum-commits
mailing list