>>              except yum.Errors.YumBaseError, e:
>> -                return 1, [str(e)]
>> +                return 1, [to_utf8(e)]

> This can't be "right", although I wouldn't be shocked to find out the
> original is "wrong" in some cases.

str(e) is certainly wrong.  It calls __str__() method which returns
'e.value', possibly a unicode string.  str() then tries to convert 
it to <type 'str'> with ascii codec, triggering an exception.

to_utf8(e) is wrong, too.  It does nothing (returns e), but the logging 
module later does unicode(e), and that's fine.

> At a guess it should probably be [exception2msg(e)], might as well put
> that in a different patch though.

exception2msg() is in utils.py, and cli.py can't import that module
without major code re-shuffling because it extends class YumBaseCli
which is in the middle of cli.py

But, all what exception2msg() really does is 'to_unicode(e.value)',
and YumBaseError.__unicode__() implements exactly the same thing.
So, I suggest using [unicode(e)] instead.  Is that ok?

[e] would work too, but we probably don't want exception instances
to appear in low-level code.
_______________________________________________
Yum-devel mailing list
[email protected]
http://lists.baseurl.org/mailman/listinfo/yum-devel

Reply via email to