[Yum-devel] [PATCH] YumBaseError: safe str(e). BZ 963698
Zdenek Pavlas
zpavlas at redhat.com
Fri May 17 07:05:23 UTC 2013
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'
---
yum/Errors.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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)
--
1.7.11.7
More information about the Yum-devel
mailing list